Issues Growing Root Disk
I'd generated a standard RHEL 6 AMI for use by my organization (our IA requirements mean that LVM on AWS/EBS is mandatory). I've had a couple of customers who complained "the root disk's partitioning is too small and when we allocate extra disk space to it in the cloud console, the extra space goes unused". Wasn't a use-case I was anticipating, but figured "I'll take a stab at sorting it out." I ended up updating the initramfs scripts that handle doing the resizing of the partition hosting /. The hacked initramfs pre-mount script sorta works - sfdisk sees the extended partition:
# sfdisk -l -uM /dev/xvda
Disk /dev/xvda: 3263 cylinders, 255 heads, 63 sectors/track
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End MiB #blocks Id System
/dev/xvda1 1 476 476 487424 83 Linux
/dev/xvda2 477 25595- 25119- 25721599+ 8e Linux LVM
/dev/xvda3 0 - 0 0 0 Empty
/dev/xvda4 0 - 0 0 0 Empty
However, the sizes seen by lsblk (and, apparently by extension, pvresize), still shows the old size-value for /dev/xvda2:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 25G 0 disk
├─xvda1 202:1 0 476M 0 part /boot
└─xvda2 202:2 0 19.5G 0 part
├─VolGroup00-rootVol (dm-0) 253:0 0 4G 0 lvm /
├─VolGroup00-swapVol (dm-1) 253:1 0 2G 0 lvm
├─VolGroup00-homeVol (dm-12) 253:12 0 1G 0 lvm /home
├─VolGroup00-varVol (dm-13) 253:13 0 2G 0 lvm /var
├─VolGroup00-logVol (dm-14) 253:14 0 2G 0 lvm /var/log
└─VolGroup00-auditVol (dm-15) 253:15 0 8.5G 0 lvm /var/log/audit
Any ideas on how I get the run-time OS's higher-level storage tools to see the extra space that sfdisk/fdisk see?
Responses
Unfortunately higher level storage tools (like lvm, multipath) will not see new space until underlying block device size is increased. Also you have to manually resize lvm after underlying block device (which is used for pv) size is increased.
In your case, I see that lvm is present on partition device (xvda2) so here additional steps are required.
Below are general steps to achieve same :
1) Increase size of disk using cloud provider tools
2) if reboot possible then reboot system to see new size, otherwise perform scsi rescan to see new size
3) in your case, you have to increase size of partition device (xvda2) as well. This is challenging part.
Take latest backup of data.
To increase xvda2, go to rescue mode and do not mount root file system. here first delete this partition using fdisk and then re-create it with same starting cylinder and end cylinder with last cylinder of disk.
4) Now size of xvda2 is increased, boot system and then just perform pvresize, vgresize and lvresize to see new size at lvm layer
5) increase file system using resize2fs
Other easy way is to add new disk to system, perform scsi rescan to see it (https://access.redhat.com/solutions/3941). Once disk is detected , then pvcreate on it, vgextend , lvextend (https://access.redhat.com/solutions/1265413).
Hope above answer your query.
Regards Ajit Mote
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
