/[gentoo]/xml/htdocs/doc/en/lvm2.xml
Gentoo

Contents of /xml/htdocs/doc/en/lvm2.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download) (as text)
Sun Jul 4 16:32:45 2004 UTC (10 years, 5 months ago) by swift
Branch: MAIN
Changes since 1.4: +5 -5 lines
File MIME type: application/xml
#55443 - Fix lvextend usage

1 neysx 1.1 <?xml version='1.0' encoding="UTF-8"?>
2 swift 1.5 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/lvm2.xml,v 1.4 2004/07/04 16:32:03 swift Exp $ -->
3 neysx 1.1 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4    
5     <guide link = "/doc/en/lvm2.xml">
6     <title>Gentoo LVM2 installation</title>
7     <author title="Author">
8     <mail link="avi@CFFtechnologies.com">Avi Schwartz</mail>
9     </author>
10     <author title="Contributor">
11     <mail link="rajiv@gentoo.org">Rajiv Manglani</mail>
12     </author>
13     <author title="Editor">
14     <mail link="neysx@gentoo.org">Xavier Neys</mail>
15     </author>
16    
17     <abstract>
18     This guide describes how to setup your Gentoo machine using the Logical Volume
19     Manager version 2 (LVM2).
20     </abstract>
21    
22     <license/>
23    
24 swift 1.5 <version>2.0.2</version>
25     <date>July 04, 2004</date>
26 neysx 1.1
27     <chapter>
28     <title>Introduction</title>
29     <section>
30     <body>
31 swift 1.4
32 neysx 1.1 <p>
33     This guide is based on an example with two IDE hard disks. It means that you
34     will more than likely need to change the drive, partition names and partition
35     sizes to match your own setup and needs.
36     </p>
37    
38     <warn>
39     This document is not intended to be an LVM2 tutorial. It serves as a
40     supplement to the Gentoo installation procedure as described in the <uri
41 swift 1.4 link="/doc/en/handbook/handbook-x86.xml?part=1&amp;chap=0">Handbook, Part
42     1</uri>. Make sure you <c>read</c> the Gentoo Installation Manual
43     <c>before</c> you start your installation process.
44 neysx 1.1 </warn>
45    
46     <note>
47     For a complete LVM HOWTO point your browser to
48     <uri>http://tldp.org/HOWTO/LVM-HOWTO</uri>
49     </note>
50 swift 1.4
51 neysx 1.1 </body>
52     </section>
53     <section>
54     <title>Initial requirements</title>
55     <body>
56 swift 1.4
57 neysx 1.1 <p>
58     If you do a fresh install of Gentoo, you will need to use a bootable CD with
59     LVM2 support such as a Gentoo LiveCD. You can find the LiveCD for an x86
60     architecture on our <uri
61     link="http://www.gentoo.org/main/en/mirrors.xml">mirrors</uri> under
62     <path>/releases/x86/2004.0/livecd/universal</path>. Other architectures might
63     be supported as well.
64     </p>
65    
66     <p>
67     It you install LVM2 on a currently running system with some spare hard disk
68     space, you will need to enable the LVM2 module (<path>dm-mod</path>). This
69     module is available in <path>gentoo-sources</path>, in
70     <path>development-sources</path> and in <path>gentoo-dev-sources</path>.
71     Compiling your kernel and getting LVM2 to work is covered later in this guide.
72     </p>
73 swift 1.4
74 neysx 1.1 </body>
75     </section>
76     <section>
77     <title>Partitions</title>
78     <body>
79 swift 1.4
80 neysx 1.1 <p>
81     Our example system has 2 IDE hard disks and will be partitioned as follows:
82     </p>
83    
84     <ul>
85 swift 1.4 <li>/dev/hda1 -- /boot</li>
86     <li>/dev/hda2 -- (swap)</li>
87     <li>/dev/hda3 -- /</li>
88     <li>/dev/hda4 -- Will be used by LVM2</li>
89     <li>/dev/hdb1 -- Will be used by LVM2</li>
90 neysx 1.1 </ul>
91    
92     <impo>
93     Pay attention to the partition names as it is easy to confuse the a's and b's,
94     and the partition numbers. One false move could wipe out the wrong partition.
95     You have been warned!
96     </impo>
97    
98     <p>
99     OK, time to start...
100     </p>
101 swift 1.4
102 neysx 1.1 </body>
103     </section>
104     </chapter>
105    
106     <chapter>
107     <title>Installation</title>
108     <section>
109     <body>
110    
111 swift 1.4 <p>
112 neysx 1.1 Follow the handbook until chapter <c>4. Preparing the Disks</c>
113 swift 1.4 </p>
114 neysx 1.1
115 swift 1.4 <p>
116 neysx 1.1 Use <c>fdisk</c> as described in the handbook, but use the partition scheme
117     mentioned above as an example. It is only <e>an example</e>, adapt it to your
118     own needs.
119 swift 1.4 </p>
120 neysx 1.1
121 swift 1.4 <p>
122 neysx 1.1 Create a small physical /boot partition (hda1). In this example, /boot will be
123     not managed by LVM2. This partition will contain your bootloader and your
124     kernel(s). A 64MB partition should be well enough for quite a few kernel
125     generations.
126 swift 1.4 </p>
127 neysx 1.1
128 swift 1.4 <p>
129 neysx 1.1 Create a swap partition (hda2) and activate it.
130 swift 1.4 </p>
131    
132 neysx 1.1 <pre caption="Activating the swap partition">
133     # <i>mkswap /dev/hda2</i>
134     # <i>swapon /dev/hda2</i>
135     </pre>
136    
137 swift 1.4 <p>
138 neysx 1.1 Create a / (root) partition (hda3). If you are interested in trying to put
139     your root partition under LVM management (which we do not recommend), see the
140     resources section at the end of this guide for a link to a mini-howto on how to
141     do this. The size of the root partition need not be large if you will keep
142     <path>/opt /usr /home /var</path> and <path>/tmp</path> in an LVM2 Volume Group
143     (vg). In this case, 150M is sufficient.
144 swift 1.4 </p>
145 neysx 1.1
146     <note>
147     It is <b>not</b> recommended to put the following directories in an
148 swift 1.4 LVM2 partition: <path>/etc</path>, <path>/lib</path>, <path>/mnt</path>,
149     <path>/proc</path>, <path>/sbin</path>, <path>/dev</path>, <path>/root</path>.
150 neysx 1.1 This way, you would still be able to log into your system (crippled, but
151     still somewhat usable, as root) if something goes terribly wrong.
152     </note>
153    
154 swift 1.4 <p>
155 neysx 1.1 Assuming the /boot, swap and root partitions do not use the whole physical disk,
156     create a fourth partition on this disk and set it to type 8e (Linux LVM).
157     If you have more physical drives you would like to use with LVM, create
158     one partition on each and give them the same type (8e).
159 swift 1.4 </p>
160 neysx 1.1
161     <note>
162     Considering the huge size of current disks, you might consider splitting your
163     hard disks into smaller partitions instead of creating a big partition that
164     will be added to an LVM2 volume group in one block. LVM2 makes it easy to
165     extend your volumes after all. This leaves you some unallocated partitions you
166     might need to use outside of an LVM2 group. In short, don't use your disk space
167     until you know you need it. As an example, one contributor had split his
168     160&nbsp;Gb hard disk into 8 partitions of 20&nbsp;Gb each.
169     </note>
170    
171 swift 1.4 <p>
172 neysx 1.1 Load the LVM2 <path>dm-mod</path> module. For some reason, this module has been
173     compiled into the kernel 2.6 (named <c>smp</c>) on the Gentoo LiveCD. If you
174     used this kernel instead of the default 2.4 (named <c>gentoo</c>), you can skip
175     this step or ignore the warning you will get.
176 swift 1.4 </p>
177 neysx 1.1
178     <pre caption="Loading the LVM2 module">
179     # <i>modprobe dm-mod</i>
180     </pre>
181    
182 swift 1.4 <p>
183 neysx 1.1 Scan and activate LVM:
184 swift 1.4 </p>
185    
186 neysx 1.1 <pre caption="Activating LVM">
187     <comment>(Avoid scanning your cdrom)</comment>
188     # <i>echo 'devices { filter=["r/cdrom/"] }' >/etc/lvm/lvm.conf</i>
189     # <i>vgscan</i>
190     Reading all physical volumes. This may take a while...
191     No volume groups found
192     </pre>
193    
194 swift 1.4 <p>
195 neysx 1.1 Prepare the partitions.
196 swift 1.4 </p>
197 neysx 1.1
198     <pre caption="Preparing the partitions">
199     # <i>pvcreate /dev/hda4 /dev/hdb1</i>
200     No physical volume label read from /dev/hda4
201     Physical volume "/dev/hda4" successfully created
202     No physical volume label read from /dev/hdb1
203     Physical volume "/dev/hdb1" successfully created
204     </pre>
205    
206 swift 1.4 <p>
207 neysx 1.1 Setup a volume group. A volume group is the result of combining several
208     physical units into a single logical device.
209 swift 1.4 </p>
210 neysx 1.1
211     <p>
212     In our example, <path>/dev/hda1</path>, <path>/dev/hda2</path> and
213     <path>/dev/hda3</path> are the <path>/boot</path>, swap and root partitions so
214     we need to combine <path>/dev/hda4</path> and <path>/dev/hdb1</path>. It can be
215     done with a single command, but, as an example, we will create our volume group
216     and extend it.
217     </p>
218    
219     <pre caption="Creating and extending a volume group">
220     <comment>(Create a volume group named vg)</comment>
221     # <i>vgcreate vg /dev/hda4</i>
222     /etc/lvm/backup: fsync failed: Invalid argument <comment>(Ignore this warning)</comment>
223     Volume group "vg" successfully created
224     <comment>(Extending an existing volume group)</comment>
225     # <i>vgextend vg /dev/hdb1</i>
226     /etc/lvm/backup: fsync failed: Invalid argument <comment>(Ignore this warning, again and later as well)</comment>
227     Volume group "vg" successfully extended
228     </pre>
229    
230 swift 1.4 <p>
231 neysx 1.1 Create the logical volumes. Logical volumes are the equivalent of partitions
232     you would create using fdisk in a non LVM2 environment. In our example, we
233     create the following partitions:
234 swift 1.4 </p>
235 neysx 1.1
236     <table>
237     <tr>
238 swift 1.4 <th>Directory</th>
239     <th>Size</th>
240 neysx 1.1 </tr>
241     <tr>
242 swift 1.4 <ti>/usr</ti>
243     <ti>10 GB</ti>
244 neysx 1.1 </tr>
245     <tr>
246 swift 1.4 <ti>/home</ti>
247     <ti>5 GB</ti>
248 neysx 1.1 </tr>
249     <tr>
250 swift 1.4 <ti>/opt</ti>
251     <ti>5 GB</ti>
252 neysx 1.1 </tr>
253     <tr>
254 swift 1.4 <ti>/var</ti>
255     <ti>10 GB</ti>
256 neysx 1.1 </tr>
257     <tr>
258 swift 1.4 <ti>/tmp</ti>
259     <ti>2 GB</ti>
260 neysx 1.1 </tr>
261     </table>
262    
263     <p>
264     Since we are going to use LVM2, we should not worry too much about partition
265     sizes because they can always be expanded as needed.
266     </p>
267    
268     <note>
269     As Terje Kvernes commented, it is easier to increase the size of a partition
270     then to shrink it. You might want therefore to start with smaller partitions
271     and increase their size as needed.
272     </note>
273    
274     <pre caption="Creating and extending logical volumes">
275     # <i>lvcreate -L10G -nusr vg</i>
276     Logical volume "usr" created <comment>(Further similar messages not displayed)</comment>
277     # <i>lvcreate -L5G -nhome vg</i>
278     # <i>lvcreate -L5G -nopt vg</i>
279     # <i>lvcreate -L10G -nvar vg</i>
280     # <i>lvcreate -L2G -ntmp vg</i>
281 swift 1.5 <comment>(As an example, let's extend a logical volume with 5 extra Gbytes)</comment>
282     # <i>lvextend -L+5G /dev/vg/home</i>
283 neysx 1.1 </pre>
284    
285 swift 1.4 <p>
286 neysx 1.1 Create filesystems on the logical volumes the same way you would on a regular
287     partition. We use ext3 on the logical volumes but any filesystem of your
288     choice will work:
289 swift 1.4 </p>
290 neysx 1.1
291     <pre caption="Creating the filesystems">
292     # <i>mke2fs -j /dev/vg/usr</i>
293     # <i>mke2fs -j /dev/vg/home</i>
294     # <i>mke2fs -j /dev/vg/opt</i>
295     # <i>mke2fs -j /dev/vg/var</i>
296     # <i>mke2fs -j /dev/vg/tmp</i>
297     </pre>
298    
299 swift 1.4 <p>
300 neysx 1.1 Mount your partitions as described in the handbook and mount your LVM2 logical
301     volumes as if they were partitions. Replace the usual <path>/dev/hdxx</path>
302     with <path>/dev/vg/logical_volumename</path>.
303 swift 1.4 </p>
304 neysx 1.1
305     <pre caption="Mounting your logical volumes">
306     <comment>(Make sure you have mounted your root partition as described in the handbook first)</comment>
307     # <i>mkdir /mnt/gentoo/usr</i>
308     # <i>mount /dev/vg/usr /mnt/gentoo/usr</i>
309     # <i>mkdir /mnt/gentoo/home</i>
310     # <i>mount /dev/vg/home /mnt/gentoo/home</i>
311     # <i>mkdir /mnt/gentoo/opt</i>
312     # <i>mount /dev/vg/opt /mnt/gentoo/opt</i>
313     # <i>mkdir /mnt/gentoo/var</i>
314     # <i>mount /dev/vg/var /mnt/gentoo/var</i>
315     # <i>mkdir /mnt/gentoo/tmp</i>
316     # <i>mount /dev/vg/tmp /mnt/gentoo/tmp</i>
317     </pre>
318    
319     <note>
320     The rest of the installation handbook is mostly unchanged so we shall not
321     walk you through it again except to point out differences.
322     </note>
323    
324 swift 1.4 <p>
325 neysx 1.1 When configuring your kernel, make sure to configure your kernel to
326     support LVM2. Select the LVM2 module as follows:
327 swift 1.4 </p>
328 neysx 1.1
329     <pre caption="Selecting the LVM2 module in a kernel 2.4.x">
330     Multi-device support (RAID and LVM) ---&gt;
331     [*] Multiple devices driver support (RAID and LVM)
332     &lt; &gt; RAID support
333     <comment>(Note that LVM is not selected on purpose, this was for LVM1)</comment>
334     &lt; &gt; Logical volume manager (LVM) support
335     &lt;M&gt; Device-mapper support
336     &lt; &gt; Mirror (RAID-1) support
337     </pre>
338    
339     <pre caption="Selecting the LVM2 module in a kernel 2.6.x">
340     Device Drivers ---&gt;
341     Multi-device support (RAID and LVM) ---&gt;
342     [*] Multiple devices driver support (RAID and LVM)
343     &lt; &gt; RAID support
344     &lt;M&gt; Device mapper support
345     </pre>
346    
347     <p>
348     The compiled module is called <path>dm-mod.ko</path>
349     </p>
350    
351     <p>
352     After you have built your kernel and installed its modules, add the following
353     line to your <path>/etc/modules.autoload.d/kernel-{KV}</path> where {KV}
354     represents your kernel version (2.4 or 2.6) so that the LVM2 module gets loaded
355     when your machine is booted:
356     </p>
357    
358     <pre caption="Adding the LVM2 module into /etc/modules.autoload.d/kernel-2.6">
359     # <i>nano -w /etc/modules.autoload.d/kernel-2.6</i>
360     <comment>(Add the following line)</comment>
361     dm-mod
362     </pre>
363    
364     <p>
365     Now, install the lvm2 package.
366     </p>
367    
368     <impo>
369     Make sure your <path>/usr/src/linux</path> link points to the kernel sources you
370     are using because the lvm2 ebuild depends on the device-mapper ebuild which
371     will check the presence of a required source file under
372     <path>/usr/src/linux/include/linux</path>.
373     </impo>
374    
375     <pre caption="Emerging the LVM2 package">
376     # <i>emerge lvm2</i>
377     <comment>(Prevent lvm2 from probing your cdrom)</comment>
378     # <i>echo 'devices { filter=["r/cdrom/"] }' >> /etc/lvm/lvm.conf</i>
379     </pre>
380    
381 swift 1.4 <p>
382 neysx 1.1 When editing your <path>/etc/fstab</path> file, follow the handbook and add
383     your LVM2 logical volumes as needed. Again, here are a few lines needed for
384     our example:
385 swift 1.4 </p>
386 neysx 1.1
387     <pre caption="Extract of /etc/fstab">
388     /dev/hda1 /boot ext3 noauto,noatime 1 1
389     /dev/hda2 none swap sw 0 0
390     /dev/hda3 / ext3 noatime 0 0
391     # Logical volumes
392     /dev/vg/usr /usr ext3 noatime 0 0
393     /dev/vg/home /home ext3 noatime 0 0
394     /dev/vg/opt /opt ext3 noatime 0 0
395     /dev/vg/var /var ext3 noatime 0 0
396     /dev/vg/tmp /tmp ext3 noatime 0 0
397     </pre>
398    
399 swift 1.4 <p>
400 neysx 1.1 When you reach the end of the installation part of the handbook, don't forget
401     to umount all your LVM2 logical volumes as well and for a good measure run the
402     following command before you reboot:
403 swift 1.4 </p>
404 neysx 1.1
405     <pre caption="Shutting down LVM2">
406     # <i>vgchange -an</i>
407     </pre>
408    
409 swift 1.4 <p>
410 neysx 1.1 Restart your machine and all partitions should be visible and mounted.
411 swift 1.4 </p>
412    
413 neysx 1.1 </body>
414     </section>
415     </chapter>
416    
417     <chapter>
418     <title>Resources</title>
419     <section>
420     <body>
421 swift 1.4
422 neysx 1.1 <ul>
423 swift 1.4 <li>
424     The official <uri link="http://sources.redhat.com/lvm2">LVM2 home page</uri>
425     </li>
426     <li>
427     The <uri link="http://tldp.org/HOWTO/LVM-HOWTO">LVM Howto</uri>
428     </li>
429     <li>
430     Daniel Robbins's articles on LVM at IBM's DeveloperWorks:
431     <uri>http://www-106.ibm.com/developerworks/linux/library/l-lvm/?dwzone=linux</uri>
432     and
433     <uri>http://www-106.ibm.com/developerworks/linux/library/l-lvm2.html?dwzone=linux</uri>
434     </li>
435     <li>
436     How to boot your root FS off of LVM1:
437     <uri>http://www.the-infinite.org/archive/docs/lvm/howto-boot-off-root-lv.txt</uri>
438     </li>
439 neysx 1.1 </ul>
440    
441     </body>
442     </section>
443     </chapter>
444 swift 1.4
445 neysx 1.1 <chapter>
446     <title>Acknowledgements</title>
447     <section>
448     <body>
449    
450     <p>
451     Thanks <mail link="bangert@gentoo.org">Thilo Bangert</mail> and <mail
452     link="terjekv@math.uio.no">Terje Kvernes</mail> for their help and comments on
453     this document.
454     </p>
455    
456     </body>
457     </section>
458     </chapter>
459     </guide>

  ViewVC Help
Powered by ViewVC 1.1.20