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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.20