JRehkemper.de

Rescan Disk Size

Sometimes one needs to rescan the disks of a system. For example after increasing the disk size of a virtual machine.
To do that, there are a few options.

sg3_utils

The easiest is to use the sg3_utils which probably need to be installed first.

$ dnf install sg3_utils

Once that is done, you can use the rescan-scsi-bus command.

$ rescan-scsi-bus -s

The -s parameter will register size-changes as well and not just new disks.

/sys

If you do not have sg3_utils installed and don’t want to, you can use the /sys-fs as well.
For this to work, you need to now the name of the drive, you want to rescan.
You can probably find it with lsblk.
Then you can do the following.

$ echo "1" > /sys/class/block/<drive-name>/device/rescan
# for example /dev/sdb
$ echo "1" > /sys/class/block/sdb/device/rescan

This will trigger the Kernel to rescan this device and detect size-changes.

profile picture of the author

Jannik Rehkemper

I'm an professional Linux Administrator and Hobby Programmer. My training as an IT-Professional started in 2019 and ended in 2022. Since 2023 I'm working as an Linux Administrator.