RHEL 7 supports online disk resize with active partition tables on disk
One of the interesting features in RHEL 7 is the fact that it supports online disk re-sizing even if there is an active partitioning table on the disk. This feature is interesting in case you want to re-size your virtual disk. You can do this online for example in VMWare. If you have a LVM partition on the disk you want to resize then you need to perform the steps described in this article from Red Hat.
In order to resize online a partition which is in use please observe the following steps:
First you need to resize your virtual disk (in my case sdc) within your virtualization platform. Afterwards you need to re-scan the device to tell the kernel about the new disk size:
echo 1 > /sys/class/block/sdc/device/rescan
Then you need to remove the existing partition table and create it new.
parted -s /dev/sdc rm 1 parted -s /dev/sdc mkpart primary 1 100% parted -s /dev/sdc set 1 lvm on
HINT: This will NOT delete your partition physically from your hard disk. It only tells the kernel to create a new partition table.
Now we use partx with option “-u” on the block device to update the in-memory kernel partition table from the on-disk partition table:
partprobe partx -u /dev/sdc
Now you should verify the new disk size:
cat /proc/partitions | grep -i sdc
If everything looks good then you can re-size the physical volume as well as the logical volume and the residing filesystem:
pvresize /dev/sdc1 lvresize -L 50G /dev/vg_data/appslv xfs_growfs /apps/
Comments are closed.