How to extend Logical Volume using lvextend in Linux ?

Today we will see how to increase Logical volume size when we have space available in our Volume Group.  
	If the space is not available then you need to check PV size and if any spare disk available on the server.  
	1. First check the partition if the selected partition is a LV and lies in VG(Volume Group).  
	[root@cf222 ~]# df -h /opt/  
	Filesystem                                                   Size  Used Avail Use% Mounted on  
	/dev/mapper/VolGroup00-opt_vol                      4.0G  3.8G     0 100% /opt  
	/dev/mapper are the links to original devices which are in /dev/VGNAME. So to find the original LV name, run below command:  
	[root@cf121 ~]# lvdisplay /dev/mapper/VolGroup00-opt_vol  
	  --- Logical volume ---  
	  LV Name                /dev/VolGroup00/opt_vol  
	  VG Name                VolGroup00  
	  LV UUID                g0mIoQ-SQ9S-YmR5-I4ZY-Vexc-KxpK-r3Uld5  
	  LV Write Access        read/write  
	  LV Status              available  
	  # open                 1  
	  LV Size                16.00 GB  
	  Current LE             512  
	  Segments               2  
	  Allocation             inherit  
	  Read ahead sectors     0  
	  Block device           253:2  
	2. Here we can see that this LV lies in VG named VolGroup00. So lets view this VG properties.  
	[root@cf121 ~]# vgdisplay VolGroup00  
	  --- Volume group ---  
	  VG Name               VolGroup00  
	  System ID  
	  Format                lvm2  
	  Metadata Areas        1  
	  Metadata Sequence No  11  
	  VG Access             read/write  
	  VG Status             resizable  
	  MAX LV                0  
	  Cur LV                8  
	  Open LV               8  
	  Max PV                0  
	  Cur PV                1  
	  Act PV                1  
	  VG Size               68.06 GB  
	  PE Size               32.00 MB  
	  Total PE              2178  
	  Alloc PE / Size       1022 / 29.94 GB  
	  Free  PE / Size       1156 / 38.12 GB  
	  VG UUID               rwWQQ2-3dCn-YjLq-4JoB-Tbui-VcYN-IQLGnp  
	Here we can see that this VG has 36GB of free space. So we can extend any LV inside this VG upto this limit.  
	3. Now to increase the LV size just run lvextend command.  
	[root@cf222 ~]# lvextend -L6G /dev/VolGroup00/opt_vol  
	  /dev/cdrom: open failed: Read-only file system  
	  Extending logical volume opt_vol to 6.00 GB  
	  Logical volume opt_vol successfully resized  
	Here –L extends the LV to mentioned size. Please use this command with caution because +L and –L denotes different meaning with lvextend.  
	Here we have increased the LV size, but the recalculation of the increased blocks can only be done on the un-mounted partition. So we need to umount this partition /opt.  
	Now umount /opt partition.  
	[root@cf222 ~]# umount /opt/  
	Now run fsck for filesystem check.  
	[root@cf222 ~]# e2fsck -f /dev/VolGroup00/opt_vol  
	e2fsck 1.35 (28-Feb-2004)  
	Pass 1: Checking inodes, blocks, and sizes  
	Pass 2: Checking directory structure  
	Pass 3: Checking directory connectivity  
	Pass 4: Checking reference counts  
	Pass 5: Checking group summary information  
	/dev/VolGroup00/opt_vol: 92001/524288 files (1.4% non-contiguous), 866982/1048576 blocks  
	Execute resize2fs to recalculate LV size.  
	[root@cf222 ~]# resize2fs /dev/VolGroup00/opt_vol  
	resize2fs 1.35 (28-Feb-2004)  
	Resizing the filesystem on /dev/VolGroup00/opt_vol to 1572864 (4k) blocks.  
	The filesystem on /dev/VolGroup00/opt_vol is now 1572864 blocks long.  
	Now mount it back.  
	[root@cf222 ~]#mount /opt  
	[root@cf222 ~]# df -h /opt/  
	Filesystem                                             Size  Used Avail Use% Mounted on  
	/dev/mapper/VolGroup00-opt_vol                 6.0G  3.3G  2.5G  58% /opt  
	[root@cf222 ~]#  
	Here we can see the LV size is increased now by 2GB.  
0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments