/[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.16 - (hide annotations) (download) (as text)
Mon Oct 3 22:49:15 2005 UTC (8 years, 6 months ago) by rane
Branch: MAIN
Changes since 1.15: +8 -5 lines
File MIME type: application/xml
LiveCD -> Installation CD, fixed link to install cds at mirrors and link to mirrors page

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

  ViewVC Help
Powered by ViewVC 1.1.20