I have a CentOS 5 VM and I've just increased the VM disk from 10G to 20G, but I cannot get fdisk to see the new disk size without a reboot.
I've tried echo 1 > /sys/block/sda/device/rescan
, it seems to indicate it can see the new size, but when I go to fdisk to create a new partion it still sees the disk as 10G.
Any ideas?
I had to deal with a similar problem, on a SLES 11 server. The LVM was built with raw disks, running on VMWare ESXi
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
But pvdisplay was still showing the 'old' disk size. It was necessary to do a
for the kernel to learn the new disk size of /dev/sdd
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:
For me that returned
Then just issue the rescan command
That should help. :)
after first doing
echo 1 > /sys/block/sda/device/rescan
pvresize /dev/sda
did the trick for meIf 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....
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:
To detect changes to existing disk:
To detect new disk:
To find X in the first situation you can use
fdisk -l
.https://kerneltalks.com/disk-management/how-to-rescan-disk-in-linux-after-extending-vmware-disk/
I know this maybe a little late, but I'm running KVM on the host. To get the disk size change I had to trigger it on the host, not the guest. In my case it was
lvextend -L+4G /dev/<volume group>/<volume>
virsh qemu-monitor-command <vm name from virsh list> --hmp "info block"
virsh qemu-monitor-command <vm name> --hmp "block_resize drive-virtio-disk2 <new size>"
I had previously run commands like
echo "- - -" > /sys/class/scsi_host/host1/scan
but nothing changed until I ran the thevirsh qemu-monitor-command -hmp
commandOn CentOS 7, I used
rescan-scsi-bus.sh -s
for this.The
-s
switch specifically instructsrescan-scsi-bus.sh
to scan for resized disks.rescan-scsi-bus.sh -s
can be found in the sg3_utils package.You have to reboot, there's no way around that.