Quick How To on Logical Volume Manager (LVM)

How to create / mange partitions using logical-volume-manager (LVM).

In computer storage, logical volume management or LVM provides a method of allocating space on mass-storage devices that is more flexible than conventional partitioning schemes. In particular, a volume manager can concatenate, stripe together or otherwise combine partitions into larger virtual ones that administrators can re-size or move, potentially without interrupting system use.
Volume management represents just one of many forms of storage virtualization; its implementation takes place in a layer in the device-driver stack of an OS (as opposed to within storage devices or in a network).
Important terms :
PV : Physical Voume : hard disks, harddisk partitions or LUN (Logical Unit Numbers).
VG : Volume Group : One physical volume or multiple physical volumes can make one volume group.
LV : Logical Volume : one volume group or multiple volume groups can make one logical volume.

Scenario 1 : You have some free space (unallocated) on a hard drive and you want to create different logical volumes after OS installation. Also, you have already created partitions using LVM during OS installation. Centos / RedHat and Fedora does create LVM by default during installation.
Please refer following screen shoot. I have used 3 commands. pvscan , vgscan , lvscan.

pvcreate, vgcreate, lvcreate, pvscan, vgscan, lvscan,







I am using centos 5.7 for this tutorial. By default system has created physical volume called /dev/vda2pvscan command is used to list current physical volumes in linux.
Then you can see that 1 volume group VolGroup00 is created.vgscan command is used to list current volume groups on your linux (GNU/Linux) system.
The actual partition we can mount is called logical volume. lvscan command is used to list actual partitions or logical disks.  /dev/VolGroup00/LogVol00 is one of the logical volume on my system.

Steps to create new logical volume:
e.g you have added a new disk to your server and it is listed as /dev/vdb block device under /dev directory on your system. vd is notation for virtual disk. it could be xvdb or xvdc or xvdd if you are using citrix virtualization. It could be /dev/sdb or /dev/sdc or /dev/sdd if the disk is physical disk or VMWare virtualization.

1. pvcreate /dev/vdb (To create physical volume from newly added disk). this step is mandatory even if you are planning to extend your existing volume group.
2. vgcreate <volume group name> /dev/sdb
E.g vgcreate volgroup100 /dev/sdb
3. lvcreate -L+100G -n <logical volume name> <volume group name in step 2>
E.g lvcreate -L+100G logvol100 volgroup100
4. now use lvscan command to list all logical volume. you will able to see newly added LV.
5. now we need to format newly created logical volume so that we can mount it on system.
mkfs.ext4 /dev/volgroup100/logvol100

Share this post

Post Comment