lvm2

Creating

Here is a mini-HOWTO, a longer one is available here.

First if you are on a setup cd, you need to

modprobe dm-mod

and

vgchange -a y

The first loads the device-mapper support for the kernel, the later enables the existing volume groups. This is automatically done for you on an installed Frugalware system.

You need to decide what physical partitions to use for LVM. In this mini-HOWTO / is /dev/hda1 and we create a big /home partition using /dev/hda2 and /dev/hdc1.

Let’s initialize them for use by LVM:

pvcreate /dev/hda2 /dev/hdc1

Create a volume group titled vg:

vgcreate vg /dev/hda2

Extend it with /dev/hdb1:

vgextend vg /dev/hdc1

Then we can create a logical volume with a size of 400G titled home:

lvcreate -L400G -nhome vg

Create a filesystem on it as usual, ie. for ext3:

mke2fs -j /dev/vg/home

And now the only task is to mount it as usual, ie:

mount /dev/vg/home /mnt/target/home

Extending

You already saw how to extend a volume group. Extending a logical volume is a bit more complex, but still easy.

If you use ext3:

umount /mnt/target/home
lvextend -L+900M /dev/vg/home
resize2fs /dev/vg/home
mount /dev/vg/home /mnt/target/home
Note
According to the manpage of resize2fs, it would have support resizing without umounting, but this does not seem to work.

If you use reiserfs:

lvextend -L+900M /dev/vg/home
resize_reiserfs /dev/vg/home

Removing

To remove a logical volume:

lvremove /dev/vg/home

To remove a physical volume from a volume group:

vgreduce vg /dev/hdc1

To remove a volume group:

vgremove vg

That’s it.