Blog

Resize disk / detect new disk cheatsheet

When you resized virtual disk on your hypervisor, you would love to have space visible in your linux, for that you need to resize block device by command

# for i in `ls /sys/block/`; do echo 1 > /sys/block/$i/device/rescan ; done
-bash: /sys/block/dm-0/device/rescan: No such file or directory
-bash: /sys/block/dm-1/device/rescan: No such file or directory
-bash: /sys/block/dm-2/device/rescan: No such file or directory
-bash: /sys/block/fd0/device/rescan: No such file or directory

(it’s actually going thru all devices that you have), if you know device name you just need to do:
echo 1 > /sys/block/DEVICE_NAME/device/rescan

And of course, you need to resize your pv. If you know device name just run (let’s say it’s sda):

#pvresize /dev/sda

If not you have oneliner:
#for i in `pvs --noheadings | awk '{print $1}'`; do pvresize $i ; done 

This will resize all that needs resizing 🙂 Now you can see correct space

Leave a Comments

Marek Knappe