Linux LVM - Logical Volume Manager: o o o o o o o o o
Linux LVM - Logical Volume Manager: o o o o o o o o o
Contents[Hide]
o o o o o o o o o
This is what we are going to do Create Partitions Create physical volumes Create Virtual Group Create Logical Volumes Create File system on logical volumes Edit /etc/fstab
This article describes a basic logic behind a Linux logical volume manager by showing real examples of configuration and usage. Although Debian Linux will be used for this tutorial, you can also apply the same command line syntax with other Linux distributions such as Red Hat, Mandriva, SuSe Linux and others.
2. Create Partitions
For this Linux lvm example you need an unpartitioned hard disk /dev/sdb. First you need to create physical volumes. To do this you need partitions or a whole disk. It is possible to run pvcreate command on /dev/sdb, but I prefer to use partitions and from partitions I later create physical volumes.
Use your preferred partitioning tool to create partitions. In this example I have used cfdisk.
# pvdisplay
# pvdisplay /dev/sdb1
Feel free to add new physical volumes to a virtual group by using the vgextend command.
create a logical volume of size 400 MB -L 400 create a logical volume of size 4 GB -L 4G
With a following example you will create a logical volume with a size of 1GB and with the name vol02:
# mkfs.ext3 -m 0 /dev/mynew_vg/vol01
the -m option specifies the percentage reserved for the super-user, set this to 0 if you wish not to waste any space, the default is
5%.
7. Edit /etc/fstab
Add an entry for your newly created logical volume into /etc/fstab
# mkdir /home/foobar
The command above does not actually increase the physical size of volume, to do that you need to:
# resize2fs
/dev/mynew_vg/vol01
Look at the figure below to see what problems you may encounter when extending a volume:
# lvdisplay
# lvremove /dev/mynew_vg/vol02