/[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.1 - (show annotations) (download) (as text)
Tue Mar 30 14:18:27 2004 UTC (10 years, 4 months ago) by neysx
Branch: MAIN
File MIME type: application/xml
lvm2.xml replaces lvm.xml and is back in index.xml (#39305)

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

  ViewVC Help
Powered by ViewVC 1.1.20