LVM : A good way to utilize disks space

Scenario :

Let say , You have 5 disks each with 20 GB , now you have requirements to create FS(file system) of size 25 GB and 35GB and let rest of the space unassigned for any future needs .

Technically, this is not possible to allocate space as each disk is only 20 GB in size and we can’t use them for 25GB and 35GB partitions . So, we will use LVM(Logical Volume Manager), merge all the disks in to one large pool (volume group) and then use space from that pool for further allocation .

LVM is to serve requests where number of disks with small size can be put into a pool which can be further utilized to allocate space as per needs . Another advantage , if the pools is going to be full/packed then we can add additional disks ( pvcreate then vgextend following lvextend ) later to increase the LVM volume group size and Logical Volume sizes .

This merging will provide total space around 100 GB , out of that space we can allocate 60 GB ( 25GB+35GB) for our needs .

Logical Steps To create LVM Partitions :

Step:1 Create Physical volume

This contains the number of disks which will be later merged to get a big size of disk in one pool.

# pvcreate <disk-name> <disk-name>

Step:2 Create Volume group

This is the name of the pool which have total amount disks size which later be assigned to Logical volumes to create partitions of varying size .

# vgcreate <volumegroupname> <disks which needs to be part of this volume group name>

Step:3 Create Logical Volume

# lvcreate -L <size for lvm> -n <lvmname> <volume-groupname>

The partition of this much size will be created in below mentioned way :

/dev/vg_name/lv_name

You can now format it with ext3/ext4 FS to make it writable and mountable .

Additional notes : You can rename VG and LV names easily but make sure they are unmounted before you do these operations .

# vgrename <old_vg_name> <new_vg_name>
# lvrename <vg_name> <old_lv_name> <new_lv_name>

We will keep posting for any additional docs on LVM .

Read Also : How to extend or grow lvm partition in linux with lvextend command

Leave a Comment