Extend Logical Volume Size on Debian

How to Extend Logical Volume Size on Debian

Logical Volume (LV) is a storage area inside a Volume Group (VG). Volume Group can create during the installation of Linux Operating System (Debian, Red Hat, CentOS, Oracle Linux and etc) or after the installation of Operating System (Debian, Red Hat, CentOS, Oracle Linux and etc) by use of Logical Volume Management (LVM) concept. The benefit of Logical Volume is that, it can be easily resize (extend and reduce). There are various types of file systems that is use for logical volume or partitions. The file systems are XFS, Ext4, Ext3, Ext2 and etc. One thing to be remember is that the file system "xfs" is only have the ability to extend the size of logical volume, when logical volume have file system "xfs" the size cannot be reduce.
Extend a logical volume size means increase the size of logical volume. Here we will extend the size of logical volume "var" that have a file system "Ext4" from 2.7GB to 62.79GB as per need. We are performing the process of Extend Logical Volume on Debian 8.10 (Jessie) Linux base operating system, you can also use this process on CentOS Linux, Oracle Linux and Red Hat Linux base operating system.

To check the version of Debian 8.10 (Jessie) Linux base operating system, type the below mention command.

lsb_release -a

To check the size of Logical volumes (file systems) and fixed size file systems, type the below mention command.
df -hT
To check the physical volume size (pvs), volume group size (vgs) and logical volume size (lvs), type the below mention command.
pvs
vgs
lvs
In the above image you can see that we have one physical volume, one volume group "01-vg" and five logical volumes (home, root, swap_1, tmp and var). This is a virtual machine on VMware 6.0, We will add additional virtual hard disk to increase the size of logical volume "var". Before add the additional virtual hard disk, Use fdisk to check all hard drives and its partitions because when you will add new virtual hard disk you can find it easily. 

fdisk -l

To add the new virtual hard disk on virtual machine, right click on virtual machine "01" then click on edit settings.
how to extend logical volume size on debian

Click on "Add" for adding a new virtual hard disk on virtual machine of Debian Linux version 8.7 jessie. Choose the device "Hard Disk" then click next to continue.

Select the type of disk to use "Create a new virtual disk" then click next to continue. Provide the Disk size "70GB" (you can change the size of Disk as per your need), in Disk provisioning choose "Thick Provision Lazy Zeroed" and select the location of Disk "Store with the virtual machine" then click next to continue.
Thick Provision: It means size of virtual hard disk is fixed. Thick provision disk is provide better performance. Mostly thick provision virtual hard drive is use in SQL Servers, Application Servers and Web Servers. The difference between thick provision lazy zeroed and thick provision eager zeroed is that thick provision eager zeroed is faster and secure then thick provision lazy zeroed but thick provision eager zeroed require more time for creation as compare to thick provision lazy zeroed.
Thin Provision: It means size of virtual hard disk will increase gradually as per need. Mostly thin provision virtual hard disk is use in where less IOPS is require. IOPS stands for input/output operations per second.

In virtual device node select "SCSI" then click next to continue. To complete the process of Add Virtual Hard Disk in Debian Linux version 8.70 jessie, click on "Finish". The Virtual Hard Disk has been successfully add in virtual machine.

After add the Virtual Hard Disk on Virtual Machine, power on Virtual Machine "01". To Power on the Virtual Machine "01" right click on Virtual Machine "01" click on "Power" then click on "Power on". After Power on the Virtual Machine, check the Virtual Hard Disk is available in Debian 8.10 (Jessie) Linux base operating system or not available in Debian 8.10 (Jessie) Linux base operating system. Type the below mention command.
fdisk -l
extend logical volume size ext4 on debian
In the above image you can see that the hard drive is shown with the lable of "/dev/sdb", use fdisk to create a logical volume of newly added Virtual Hard Disk "/dev/sdb".
fdisk /dev/sdb
In the above image you can see that command "p" is use to check how much free space is available in hard disk and partition already created or not.

To create a new partition type the command "n".
extend logical volume size on debian
In the above image you can see that five steps are perform to create a partition on new Virtual Hard Disk. Here we will describe each step briefly.
Step 1: Type command "n" to create a new partition.
Step 2: Type command "p" to create a primary partition on new Virtual Hard Disk.
Step 3: Type partition number "1" for first partition, four partitions can created on single hard disk.
Step 4: For first default sector just press "Enter" key.
Step 5: For last default sector just press "Enter" key.
Type command "p" to verify the partition "/dev/sdb1" has successfully created. Change partition type from "Linux" to "Linux LVM" by use of command "t". Use Hex code 8e for Linux LVM.
extend logical volume size on debian
Type command "p" to verify the partition has successfully changed its type from "Linux" to "Linux LVM". Type command "w" to write the partition table on disk.
extend logical volume size on debian
To check the specific hard disk in detail on Debian 8.10 (Jessie) Linux base operating system, type the below mention command.
fdisk -l /dev/sdb
To create a physical volume on new Virtual Hard Disk "sdb1", type the below mention command.
pvcreate /dev/sdb1
For add the physical volume of new Virtual Hard Disk "sdb1" in volume group, type the below mention command.
vgextend 01-vg /dev/sdb1
Note: 01-vg is Volume Group.

To check the free space of each Hard Disk, type the below mention command.
pvscan
Here we are increasing the size of logical volume "var" therefore we need a path of logical volume "var". To check the path of logical volume "var", type the below mention command. This command give the complete details of logical volumes.
lvdisplay

By use of above command you can take that the require path of logical volume "var" that in this demo is "/dev/01-vg/var".To check the complete details of volume group "01-vg", type the below mention command. 

vgdisplay

By use of above command you can see that how much free size is available in Volume Group "01-vg". To extend the size of Logical Volume "var", type the below mention command. Logical Volume "var" already have 2.79GB, we are adding 60GB in logical volume "var". The total size of Logical volume will be 62.79GB.  

lvextend -L +60G /dev/01-vg/var

Resize Logical Volume "var", type the below mention command.
resize2fs /dev/01-vg/var
To check the size of Logical Volume "var", other logical volumes and fixed size volumes, type the below mention command.
df -hT
Thanks for Read this Article

Comments