How do I get Centos VM to re-read its increased Disk size WITHOUT a reboot

Solution 1:

You need to issue the rescan command to your SCSI bus.

In VMware the SCSI controller might be found in some unusual place. First find it:

find /sys -iname 'scan'

For me that returned

/sys/devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0/scan
/sys/devices/pci0000:00/0000:00:07.1/host1/scsi_host/host1/scan
/sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan

Then just issue the rescan command

echo "- - -" >/sys/devices/pci0000:00/0000:00:07.1/host0/scsi_host/host0/scan
echo "- - -" >/sys/devices/pci0000:00/0000:00:07.1/host0/scsi_host/host1/scan
echo "- - -" >/sys/devices/pci0000:00/0000:00:10.0/host0/scsi_host/host2/scan

That should help. :)

Solution 2:

I had to deal with a similar problem, on a SLES 11 server. The LVM was built with raw disks, running on VMWare ESXi

# pvcreate /dev/sdd; vgextend ....

After a while I needed to increase LVM size, but I didn't add a supplemental disk and then pvcreate + vgextend as I've done before, but I chose to increase the size of an existing disk (/dev/sdd in this case). After doing the increase in VMWare, I executed a

# rescan-scsi-bus.sh

But pvdisplay was still showing the 'old' disk size. It was necessary to do a

# echo 1 > /sys/block/sdd/device/rescan

for the kernel to learn the new disk size of /dev/sdd


Solution 3:

after first doing echo 1 > /sys/block/sda/device/rescan

pvresize /dev/sda did the trick for me


Solution 4:

If the partition table is directly in use (e.g. you have mounted filesystem using a base partition) the kernel will continue to use the old partition table until this is no longer the case. Someone once told me that if you are using LVM you can get around this....


Solution 5:

Update: Centos 6 - not possible to update partition table of active disk online, Centos 7 - it is possible to extend last partition with growpart or create new partition with fdisk and make it visible without reboot with partprobe. Probably same on ubuntu/debian. - At some point after 2.6 kernel started supporting online reread of partition table of active disk. Since question is for Centos 5 I would say no way.

If you are using partitions then you have to reboot to use new space. I didn't find a way to avoid this. If someone has let me know.

However, reboot should be done after you extend last partition on the disk or add new partition. Doesn't make sense to reboot before.

First thing you should notice after rescan is bigger disk size in fdisk and in lsblk. If you don't see it you have to play with these echo 1 and echo - - - commands.

After you see more space you can extend/add partition, then reboot, extend vg, extend lv and fs.

If you want to avoid reboot you have to assign raw sda/b/c disk to volume group without partitioning it to sda1/2/3. Then there is no need for reboot.

Partitioning was necessary some time ago when linux could not boot from LVM, but now it can.

If you do lsblk you will see partitions or lvms depending on if you are using partitions or lvm, you can have all parts if you don't use lvm or all lvms if you don't use partitions. Here is one example:

root@srv4 ~ $ lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                           8:0    0  7.3T  0 disk
├─sda1                        8:1    0  500M  0 part /boot
└─sda2                        8:2    0  7.3T  0 part
  ├─vg_srv4-LogVol13 (dm-0) 253:0    0  7.1T  0 lvm  /
  ├─vg_srv4-LogVol05 (dm-1) 253:1    0  100G  0 lvm  /var/log
  ├─vg_srv4-LogVol04 (dm-2) 253:2    0   20G  0 lvm  /var
  ├─vg_srv4-LogVol01 (dm-5) 253:5    0   20G  0 lvm  /opt
  ├─vg_srv4-LogVol00 (dm-6) 253:6    0   20G  0 lvm  /home
  ├─vg_srv4-LogVol03 (dm-7) 253:7    0   20G  0 lvm  /usr
  └─vg_srv4-LogVol02 (dm-8) 253:8    0    8G  0 lvm  /tmp

Tags:

Linux