[CentOS] Extending a CentOS disk without reboot

Mon Dec 21 19:15:08 UTC 2015
Sander Kuusemets <sander.kuusemets at ut.ee>


Today a virtual server under my administration ran out of disk space, so 
I had to get extra space to it.. while it was running, because it's an 
important web server without any kind of HA/Load Balancing (don't do 
that, kids).

So what happened, is that after another administrator had extended the 
disk from VMWare, I tried to extend it from the OS side.

Everything went well, listing my steps here:

  * echo 1 > /sys/class/scsi_device/2\:0\:0\:0/device/rescan
  * fdisk /dev/sdb (the usual, delete partition and make a new, bigger one)

Now's when the problems happened. After writing the partition table I 
got the usual "Busy" error. But I needed to do this without downtime. 
So, what did I try to get the kernel acknowledge the partition size change:

  * hdparm -z /dev/sdb
  * partx -a -v /dev/sdb
  * partprobe -s
  * echo "1" > /sys/block/sdb/device/rescan

And while dmesg reported that it recognized the partition change, LVM 
did still not see it. So eventually, I was still forced to reboot, after 
which everything (pvresize, lvresize, resize2fs) worked fine. Environment:

  * A VMWare virtual machine
  * CentOS 6.7 (Final)

Is there any other way I'm missing? Is this caused by the fact that I 
was trying to resize a partition that is under the root file system? If 
so, then is it really impossible to do it live?


Sander Kuusemets
University of Tartu, High Performance Computing, IT Specialist