Logical Volume Management

LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. With LVM, a hard drive or set of hard drives is allocated to one or more physicalvolumesLVM physical volumes can be placed on other block devices which might span two or more disks.
VG Name A Volume Group name.
Format LVM Architecture Used LVM2.
VG Access Volume Group is in Read and Write and ready to use.
VG Status Volume Group can be re sized, We can Expand more if we need to add more space.
Cur LV Currently there was 2 Logical volumes in this Volume Group.
CurPV and Act PV Currently Using Physical Disk was 1 (vda), And its active, so what we can use this volume group.
PE Size Physical Extends, Size for a disk can be defined using PE or GB size, 4MB is the Default PE size of LVM.
Creating a LVM
As mentioned above we will firstly create partitions of disks /dev/sdb & /dev/sdc with partition id 8e. Process to do that is as follows
Firstly we will prepare /dev/sdb disk for LVM, 
fdisk /dev/sdb
Type ‘n’ for creating new partition,
Next type ‘p’ for creating the primary partition (since this is new disk, partition number will be 1 )
Nest for First cylinder value & last cylinder value, press enter to use default values i.e. full hdd space
Type ‘t’ for accessing the partition followed by ‘1’ (partition number)
Now this is the part where we will enter the partition id for creating LVM i.e. 8e. Type ‘8e’ now & press ‘w’ to write changes.
We have partitioned /dev/sdb for LVM-creation, same steps are to be repeated for /dev/sdc. Once both the disks have been prepared, we will move on to next step ie. Creating physical volume,
Creating Physical Volume
To create PV, we will use ‘pvcreate’ command,
pvcreate /dev/sdb /dev/sdc
You will get confirmation that Physical Volume has been created. We can see & confirm the newly created Physical volume using ‘pvdisplay’
Creating Volume Group
Next we will create a VG of the PVs using ‘vgcreate’ command,
vgcreate vg01 /dev/sdb /dev/sdc
Here, ‘vg01’ is the name of volume group. To confirm the creation of VG, we will use ‘vgdisplay’ command
vgdisplay vg01
Creating Logical Volume
Lastly we will create Logical Volume from Volume group ‘vg01’ using ‘lvcreate’ command
lvcreate –l 25G –n lv01 vg01
Here, ‘-l 25G’ means size of logical volume, ‘-n lv01’ means the name of LV is lv01 & ‘vg01’ is the name of Volume Group. To see the information about the new LV, use ‘lvdisplay’ command
lvdsplay /dev/vg01/lv01
Now our LV has been created but before we can use it we need to assign it a file system & mount it to a point.
Assigning Filesystem & Mounting LV
We are now going to assign a filesystem to LV ‘lvo1’. We will assigning ‘ext4’ to it using ‘mkfs’,
mkfs.ext4 /dev/vg01/lv01
Our LV is now formatted with ext4 filesystem. Next we will create a mounting point for mounting lv01,
mkdir /data
& now we will mount the lv01 to /data
mount /dev/vg01/lv01 /data
But this is a temporary mount & will be unmounted if our system reboots. To permanently mount it, we need to append the /etc/fstab file with the following entry
vim /etc/fstab
/dev/vg01/lv01 /data ext4 defaults 0 0
Save & exit the file. Our lv is now ready to be used, we can add, delete files to it.


Leave a Reply

Your email address will not be published.