Rescan disk devices on a Linux VMware virtual machine without a reboot

Want to help support this blog? Try out Oh Dear, the best all-in-one monitoring tool for your entire website, co-founded by me (the guy that wrote this blogpost). Start with a 10-day trial, no strings attached.

We offer uptime monitoring, SSL checks, broken links checking, performance & cronjob monitoring, branded status pages & so much more. Try us out today!

Profile image of Mattias Geniar

Mattias Geniar, March 28, 2012

Follow me on Twitter as @mattiasgeniar

If you add a new Hard Disk virtual device to a running Virtual Machine in VMware, that VM will most likely not recognize that new disk straight away. To do a re-scan of your SCSI bus while the Virtual Machine is running, to force it to re-read all its attached hard disks, you can issue the following command.

First, find your hostbus ID.

# ls /sys/class/scsi_host        
host0

In this case, host0 is the hostbus. Next, force a rescan. Replace the host0 in the path with whatever value you may have received with the ls output above.

# echo "- - -" > /sys/class/scsi_host/host0/scan

If you run a fdisk -l now, it will display the newly added hard disk without the need to reboot your Linux virtual machine.



Want to subscribe to the cron.weekly newsletter?

I write a weekly-ish newsletter on Linux, open source & webdevelopment called cron.weekly.

It features the latest news, guides & tutorials and new open source projects. You can sign up via email below.

No spam. Just some good, practical Linux & open source content.