Introduction
This article will help you to resize a logical volume.
Procedure
First, you will want to view the mount point associated with a logical drive and the current reported size.
View the mount point associated with a logical drive and the current reported size.
You can use the df command to see the mount point that is associated with a logical drive and the current reported size:
[cptech@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 23G 24G 49% /
tmpfs 3.8G 0 3.8G 0% /dev/shm
/dev/sda1 477M 125M 327M 28% /boot
/dev/mapper/centos-home 860G 72M 816G 1% /home
[cptech@server ~]#
See the total hard disk/s size and partitions
You can utilize fdisk to see the total hard disk size and partitions. You can also use fdisk to determine which partition is being used for a logical volume. When you run fdisk, you will see that the partition is Linux LVM.
[cptech@server ~]# fdisk -l
Disk /dev/sda: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00031533
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 121535 975711232 8e Linux LVM
You can also use the lvs or pvs commands to see the partition associated with a logical volume.
[cptech@server ~]# lvs -o +devices /dev/mapper/dev/mapper/centos-home
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices
home centos -wi-ao---- 872.88g /dev/sda2(12800)
[cptech@server ~]#
[cptech@server ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 930.51g 0
lvextend
The logical volume can be increased by using the lvextend command.
For example, if you want to increase a logical volume by 5 gigabytes, you can type the following:
[cptech@server ~]# lvextend -L +5G /dev/mapper/centos-home
Extending logical volume home to 865.00 GB
Logical volume successfully resized
If you want to increase it to a specific value, you can type the following instead:
lvextend -L870G /dev/mapper/centos-home
If you run df again, you will notice that the file system doesn’t seem to detect the correct size.
[cptech@server ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 23G 24G 49% /
tmpfs 3.8G 0 3.8G 0% /dev/shm
/dev/sda1 477M 125M 327M 28% /boot
/dev/mapper/centos-home 860G 72M 816G 1% /home
xfs_growfs, resize2fs, resize4fs
For the file system to detect the new logical volume size, you will need to run xfs_growfs (for xfs file system), or either resize2fs or resize4fs (for ext2/ext3/ext4 file systems) to expand and resize the file system.
You can type the following if you are using xfs:
xfs_growfs /home
Notice that you will need to specify /home(mount point), which is associated with /dev/mapper/centos-home