# modprobe dm-mod
Before scanning and activating LVM, you might want to edit /etc/lvm/lvm.conf to exclude some devices. By default, LVM2 will scan all devices, even your CDROM which can generate error messages. In the following example, the line that allows scanning of all devices is replaced by one that rejects every device but our two IDE disks.
(Avoid scanning all devices but our disks)
# nano -w /etc/lvm/lvm.conf
(Look for the following line)
filter = [ "a/.*/" ]
(Replace it with the following one to scan /dev/hda and /dev/hdb and reject anything else)
filter = [ "a|/dev/hd[ab]|", "r/.*/" ]
(Save the file and quit nano)
# vgscan
Reading all physical volumes. This may take a while... No volume groups found
(Make any previously set up volume groups available)
# vgchange -a y
Prepare the partitions.
# pvcreate /dev/sda5 No physical volume label read from /dev/sda5 Physical volume "/dev/sda5" successfully created
Setup a volume group. A volume group is the result of combining several physical units into a single logical device.
(Create a volume group named vg)
# vgcreate vg /dev/sda5 /etc/lvm/backup: fsync failed: Invalid argument (Ignore this warning) Volume group "vg" successfully created
Create the logical volumes. Logical volumes are the equivalent of partitions you would create using fdisk in a non LVM2 environment. In our example, we create the following partitions: Directory Size /home 5 GB
Since we are going to use LVM2, we should not worry too much about partition sizes because they can always be expanded as needed.
# lvcreate -l100%FREE -nhome vg Logical volume "home" created
Create filesystems on the logical volumes the same way you would on a regular partition. We use ext3 on the logical volumes but any filesystem of your choice will work:
# mke2fs -j /dev/vg/home
Mount your partitions as described in the handbook and mount your LVM2 logical volumes as if they were partitions. Replace the usual /dev/hdxx with /dev/vg/logical_volumename.
(Make sure you have mounted your root partition as described in the handbook first)
# mount /dev/vg/home /home