This guide is based on an example with two IDE hard disks. It means that you
will more than likely need to change the drive, partition names and partition
sizes to match your own setup and needs.

This document is not intended to be an LVM2 tutorial. It serves as a
supplement to the Gentoo installation procedure as described in the Handbook, Part
1. Make sure you read the Gentoo Installation Manual
before you start your installation process.
For a complete LVM HOWTO point your browser to
http://tldp.org/HOWTO/LVM-HOWTOInitial requirements

If you do a fresh install of Gentoo, you will need to use a bootable CD with
LVM2 support such as a Gentoo LiveCD. You can find the LiveCD for an x86
architecture on our mirrors under
/releases/x86/2004.0/livecd/universal. Other architectures might
be supported as well.

It you install LVM2 on a currently running system with some spare hard disk
space, you will need to enable the LVM2 module (dm-mod). This
module is available in gentoo-sources, in
development-sources and in gentoo-dev-sources.
Compiling your kernel and getting LVM2 to work is covered later in this guide.

Partitions

Our example system has 2 IDE hard disks and will be partitioned as follows:

/dev/hda1 -- /boot

/dev/hda2 -- (swap)

/dev/hda3 -- /

/dev/hda4 -- Will be used by LVM2

/dev/hdb1 -- Will be used by LVM2

Pay attention to the partition names as it is easy to confuse the a's and b's,
and the partition numbers. One false move could wipe out the wrong partition.
You have been warned!

OK, time to start...

Installation

Follow the handbook until chapter 4. Preparing the Disks

Use fdisk as described in the handbook, but use the partition scheme
mentioned above as an example. It is only an example, adapt it to your
own needs.

Create a small physical /boot partition (hda1). In this example, /boot will be
not managed by LVM2. This partition will contain your bootloader and your
kernel(s). A 64MB partition should be well enough for quite a few kernel
generations.

Create a swap partition (hda2) and activate it.

# mkswap /dev/hda2
# swapon /dev/hda2

Create a / (root) partition (hda3). If you are interested in trying to put
your root partition under LVM management (which we do not recommend), see the
resources section at the end of this guide for a link to a mini-howto on how to
do this. The size of the root partition need not be large if you will keep
/opt /usr /home /var and /tmp in an LVM2 Volume Group
(vg). In this case, 150M is sufficient.

It is not recommended to put the following directories in an
LVM2 partition: /etc, /lib, /mnt,
/proc, /sbin, /dev, /root.
This way, you would still be able to log into your system (crippled, but
still somewhat usable, as root) if something goes terribly wrong.

Assuming the /boot, swap and root partitions do not use the whole physical disk,
create a fourth partition on this disk and set it to type 8e (Linux LVM).
If you have more physical drives you would like to use with LVM, create
one partition on each and give them the same type (8e).

Considering the huge size of current disks, you might consider splitting your
hard disks into smaller partitions instead of creating a big partition that
will be added to an LVM2 volume group in one block. LVM2 makes it easy to
extend your volumes after all. This leaves you some unallocated partitions you
might need to use outside of an LVM2 group. In short, don't use your disk space
until you know you need it. As an example, one contributor had split his
160 Gb hard disk into 8 partitions of 20 Gb each.

Load the LVM2 dm-mod module. For some reason, this module has been
compiled into the kernel 2.6 (named smp) on the Gentoo LiveCD. If you
used this kernel instead of the default 2.4 (named gentoo), you can skip
this step or ignore the warning you will get.

Setup a volume group. A volume group is the result of combining several
physical units into a single logical device.

In our example, /dev/hda1, /dev/hda2 and
/dev/hda3 are the /boot, swap and root partitions so
we need to combine /dev/hda4 and /dev/hdb1. It can be
done with a single command, but, as an example, we will create our volume group
and extend it.

The rest of the installation handbook is mostly unchanged so we shall not
walk you through it again except to point out differences.

When configuring your kernel, make sure to configure your kernel to
support LVM2. Select the LVM2 module as follows:

Multi-device support (RAID and LVM) --->
[*] Multiple devices driver support (RAID and LVM)
< > RAID support
(Note that LVM is not selected on purpose, this was for LVM1)
< > Logical volume manager (LVM) support
<M> Device-mapper support
< > Mirror (RAID-1) support

After you have built your kernel and installed its modules, add the following
line to your /etc/modules.autoload.d/kernel-{KV} where {KV}
represents your kernel version (2.4 or 2.6) so that the LVM2 module gets loaded
when your machine is booted:

Make sure your /usr/src/linux link points to the kernel sources you
are using because the lvm2 ebuild depends on the device-mapper ebuild which
will check the presence of a required source file under
/usr/src/linux/include/linux.