13

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?

  • Depending on your virtualisation platform and storage method, this may or may not be possible. Details matter. – womble Aug 31 '11 at 9:47
  • Which virtual disk type you've added: IDE or SCSI? – quanta Aug 31 '11 at 9:48
  • That first command worked for me... – Rodo Mar 1 '17 at 17:01
8

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. :)

  • 4
    ls /sys/class/scsi_host maybe faster. – quanta Aug 31 '11 at 9:52
10

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

  • 5
    echo 1 > /sys/block/sda/device/rescan worked for me on CentOS – Benedikt Köppel Apr 30 '16 at 19:37
  • -bash: /sys/module/scsi_mod/parameters/scan: Permission denied, username is root – Sarz Sep 27 '16 at 11:43
5

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

pvresize /dev/sda did the trick for me

3

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....

1

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
-5

You have to reboot, there's no way around that.

  • How about the force system to rescan? – quanta Aug 31 '11 at 9:50
  • I did have to reboot :-( – AndyM Sep 9 '11 at 12:10
  • I had to reboot too. – ondra Jun 13 '16 at 8:12
  • 1
    This is completely untrue. I have done this multiple times without rebooting. – Duncan X Simpson Jun 16 '18 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.