VMWare tips

Here is a few tips I’ve learned with VMWare virtual machines hosting Ubuntu 12.04 / 14.04.

How to refresh an upgraded disk

If you want to resize a disk at runtime, go to your VM preferences and update your disk size. Now, how to refresh the state of the disk in the virtual machine without rebooting it?

For each disk in your VM, there is a related directory in the /sys/class/scsi_devices directory. Use the following command to rescan your disk capacity:

$ echo 1 > /sys/class/scsi_device/DISK/device/rescan

How to refresh new disk

If you want to add another disk at runtime, go to your VM preferences and add a new disk. Now, how to refresh the system so it can see the new disk without rebooting the VM?

Basically, you just need to rescan the SCSI bus to which the storages are connected.

The following commands assume you have root access on the system.

Find your host bus number

$ grep mpt /sys/class/scsi_host/host?/proc_name

This will return a line like the following:

/sys/class/scsi_host/host0/proc_name:mptspi

Where host0 is the relevant bus number.

Rescan the SCSI bus

$ echo "- - -" > /sys/class/scsi_host/host0/scan
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s