LVM commands tutorial : Part 3 : Logical Volume (lvcreate, lvdisplay, lvremove)

This is last part of LVM commands tutorial. Previously we seen physical volume, volume group commands which can be seen on below links :

Logical volumes are small slices carved out of physical volumes storage space which is collectively available in volume group. For more details check LVM legends.

Command : lvcreate

This command used to create new logical volume. Logical volumes are mounted on directories as a mount point. So logical volume size is the size you want for mount point. Use command like below :

In above command you need to supply size in MB (1 GB in above example) to -L argument and volume group name in which you need to create that LV. If no name suggested in command then by default command creates LV with name /dev/vg01/lvolX (X is next avaibale number).

This command supports below options –

  • -l  : Number of LEs
  • -n : LV Name

Created LV details can be seen using command lvdisplay.

Command : lvdisplay

We seen above how to create LV, now we will see how to view details of it. This command is same as pvdisplay for PV and vgdisplay for VG. It shows you details like name, volume group it belongs to, size, permission, status, allocation policy etc.

More detailed output can be obtained with -v option. In this detailed outpout you can get the LE details where they resides and LV distribution across disks.

Command : lvremove

Removing a logical volume is data destroying task. Make sure you take backup of data within mount point then empty it and stop all user/app access to it. If LV is not empty then command will prompt you for confirmation to proceed. 

Once lvol is delete its number is again available for next new lvol which is being created in same VG. All PE assigned to this LV will be released as free PE and hence free space in VG will increase.

We will be seeing how to extend and reduce LV also how to activate or deactivate LV in next post.

Any thoughts?