In Linux, Logical Volume Manager (LVM) manages physical disk drives by using the notion of "logical" volumes. A "volume" could be a partition or an entire disk drive. Among other things, LVM allows you to create one or more logical volumes out of one or more physical volumes, resize logical volumes on-the-fly, and move logical volumes across different physical volumes. Such flexible disk management of LVM is a great advantage as re-partitioning is often necessary while you are running your system. If you would like to try out LVM, here is a 3-minute guide on how to create a Linux LVM partition.
Typically LVM comes with most Linux distros, but to make sure to install a necessary tool for LVM:
First, prepare a physical LVM partition using fdisk. After creating a new partition, make sure to set its partition type to 8e (LVM). Assume that the drive to create a physical LVM partition on is /dev/sdb.
[create a LVM partition: /dev/sdb1]
Next, create a LVM physical volume on the prepared partition /dev/sdb1:
Inside the LVM physical volume, create a LVM volume group called "my_vol" with a physical extent (PE) size of 16MB. Note that PE size needs to be a power of 2.
Create a 1GB logical volume called drive0 on volume group my_vol:
At this point, you will see /dev/my_vol/drive0 which is the device name of the LVM volume you've just created. Finally, proceed to create a filesystem and mount it as follows.
$ sudo mount -t ext3 /dev/my_vol/drive0 /mnt
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!