Pick a Free OS

LVM: The logical way to manage space

Do a ‘make menuconfig’ to configure your patched kernel. Go into “Multi-device support” and choose `Compile support’ for LVM into your kernel or make it into a module. We recommend making it into a Module. In that case, put the following two lines in your /etc/modules.conf

alias block-major-58 lvm-mod

alias char-major-109 lvm-mod

You will also require the userspace tools for LVM administration. Go to LVM/0.9 directory and compile them.



make install

Now that you have the required LVM tools installed, add “vgscan” and “vgchange –-a y” to your startup files so that, the available volume groups are initialized and available at startup before the LVM-based filesystems are mounted. This would be /sbin/init.d/boot in SuSE, and /etc/rc.d/rc.sysinit in Red Hat. Similarly add “vgchange -a n” to the shutdown script after your filesystems are unmounted. Look for the script /sbin/init.d/halt in SuSE.

Understand it!

Now, before you start using LVM, you need to look at some of the terms that you will encounter. To start with, there are Physical Volumes (PVs). These are the basic building blocks and would be the partitions that you have available. You can also use RAID volumes but we’re just working with plain old partitions. So /dev/hda6, hdb1 etc. are the PV’s.

These PV’s together form a Volume Group (VG). Basically, the effective disk space that is available in a VG is the sum total of the various PV’s that you add to the VG.

Once you have allocated enough disk space to your VG (Don’t worry about allocating space. Remember, you can add any amount of space later), you can set about creating Logical Volumes (LVs). LVs are the final containers of your data. We’'ve actually come full circle here. We started out with distinct partitions that were collated into a single storage area and now we’re creating distinct, logical partitions from the space we added to the VG.

Use it!

Now that you know a few of the buzzwords of LVM, lets go on to the command line and start using LVM. Look for some unused partitions/space that can be used for LVM. You need at least one. Create a new partition or use an existing partition. Existing partitions will lose all data so make sure there’s nothing useful on those partitions. Fdisk is a good tool to create the partitions. You will also have to set the partition type to 8e (Linux LVM).

#fdisk -l /dev/hda


/dev/hda7 2362 2616 2048256 8e Linux LVM

/dev/hda8 2617 2871 2048256 8e Linux LVM

Now initialize the partition.