/[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 - (show annotations) (download) (as text)
Mon Oct 3 22:49:15 2005 UTC (8 years, 11 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 <?xml version='1.0' encoding="UTF-8"?>
2 <!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/lvm2.xml,v 1.15 2005/09/23 13:57:32 neysx Exp $ -->
3 <!DOCTYPE guide SYSTEM "/dtd/guide.dtd">
4
5 <guide link = "/doc/en/lvm2.xml">
6 <title>Gentoo LVM2 installation</title>
7
8 <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 <!-- The content of this document is licensed under the CC-BY-SA license -->
24 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
25 <license/>
26
27 <version>2.0.11</version>
28 <date>2005-08-17</date>
29
30 <chapter>
31 <title>Introduction</title>
32 <section>
33 <body>
34
35 <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 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 </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
54 </body>
55 </section>
56 <section>
57 <title>Initial requirements</title>
58 <body>
59
60 <p>
61 If you do a fresh install of Gentoo, you will need to use a bootable CD with
62 LVM2 support such as a Gentoo Installation CD. You can find the Installation CDs for an x86
63 architecture on our <uri
64 link="/main/en/mirrors.xml">mirrors</uri> under
65 <path>/releases/x86/2005.1/installcd</path>. Other architectures might
66 be supported as well.
67 </p>
68
69 <p>
70 If you install LVM2 on a currently running system with some spare hard disk
71 space, you will need to enable the LVM2 module (<path>dm-mod</path>). This
72 module is available in <path>gentoo-sources</path> and in
73 <path>vanilla-sources</path>.
74 Compiling your kernel and getting LVM2 to work is covered later in this guide.
75 </p>
76
77 <p>
78 Not all 2.4 kernels provided by Gentoo support LVM2!
79 </p>
80
81 <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 </body>
89 </section>
90 <section>
91 <title>Partitions</title>
92 <body>
93
94 <p>
95 Our example system has two IDE hard disks and will be partitioned as follows:
96 </p>
97
98 <ul>
99 <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 </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
116 </body>
117 </section>
118 </chapter>
119
120 <chapter>
121 <title>Installation</title>
122 <section>
123 <body>
124
125 <p>
126 Follow the handbook, but with the following amendments to chapter <c>4.
127 Preparing the Disks</c>:
128 </p>
129
130 <p>
131 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 </p>
135
136 <p>
137 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 </p>
142
143 <p>
144 Create a swap partition (hda2) and activate it.
145 </p>
146
147 <pre caption="Activating the swap partition">
148 # <i>mkswap /dev/hda2</i>
149 # <i>swapon /dev/hda2</i>
150 </pre>
151
152 <p>
153 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 resources section at the end of this guide for a link to a mini-howto on how to
156 do this. The size of the root partition need not be large if you will keep
157 <path>/opt /usr /home /var</path> and <path>/tmp</path> in an LVM2 Volume Group
158 (vg). In this case, 1GB should be sufficient.
159 </p>
160
161 <note>
162 It is <b>not</b> recommended to put the following directories in an
163 LVM2 partition: <path>/etc</path>, <path>/lib</path>, <path>/mnt</path>,
164 <path>/proc</path>, <path>/sbin</path>, <path>/dev</path>, and <path>/root</path>.
165 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 <p>
170 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 </p>
175
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 <p>
187 Load the LVM2 <path>dm-mod</path> module.
188 </p>
189
190 <pre caption="Loading the LVM2 module">
191 # <i>modprobe dm-mod</i>
192 </pre>
193
194 <p>
195 Scan and activate LVM:
196 </p>
197
198 <pre caption="Activating LVM">
199 <comment>(Avoid scanning your cdrom)</comment>
200 # <i>mkdir -p /etc/lvm</i>
201 # <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 <comment>(Make any previously set up volume groups available)</comment>
206 # <i>vgchange -a y</i>
207 </pre>
208
209 <p>
210 Prepare the partitions.
211 </p>
212
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 <p>
222 Setup a volume group. A volume group is the result of combining several
223 physical units into a single logical device.
224 </p>
225
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 <p>
246 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 </p>
250
251 <table>
252 <tr>
253 <th>Directory</th>
254 <th>Size</th>
255 </tr>
256 <tr>
257 <ti>/usr</ti>
258 <ti>10 GB</ti>
259 </tr>
260 <tr>
261 <ti>/home</ti>
262 <ti>5 GB</ti>
263 </tr>
264 <tr>
265 <ti>/opt</ti>
266 <ti>5 GB</ti>
267 </tr>
268 <tr>
269 <ti>/var</ti>
270 <ti>10 GB</ti>
271 </tr>
272 <tr>
273 <ti>/tmp</ti>
274 <ti>2 GB</ti>
275 </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 then to shrink it. You might therefore want to start with smaller partitions
286 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 <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 </pre>
299
300 <p>
301 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 </p>
305
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 <p>
315 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 </p>
319
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 <p>
340 When configuring your kernel, make sure to configure your kernel to
341 support LVM2 (not all 2.4 kernels do). Select the LVM2 module as follows:
342 </p>
343
344 <pre caption="Selecting the LVM2 module in a 2.4.x kernel">
345 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 <pre caption="Selecting the LVM2 module in a 2.6.x kernel">
355 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 <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 # <i>echo 'devices { filter=["r/cdrom/"] }' >> /etc/lvm/lvm.conf</i>
395
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 </pre>
400
401 <p>
402 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 </p>
406
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 <p>
420 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 </p>
424
425 <pre caption="Shutting down LVM2">
426 # <i>vgchange -a n</i>
427 </pre>
428
429 <p>
430 Restart your machine and all partitions should be visible and mounted.
431 </p>
432
433 </body>
434 </section>
435 </chapter>
436
437 <chapter>
438 <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 <title>Resources</title>
473 <section>
474 <body>
475
476 <ul>
477 <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 </ul>
494
495 </body>
496 </section>
497 </chapter>
498
499 <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