Thursday 17 February 2011

Adding virtual hard disk to SUSE VM on Vmware without reboot

So you need to add an additional hard disk to your VM running the SUSE family of operating system, but its in production and you can not reboot it.

So how do you go about it?

Well, it is rather easy!

First, open the "edit settings" window, within the vm, either from the console menu, or by right clicking in the vm through the virtual infrastructure client. Add a hard disk and configure it with the size you require. Finally accept the changes and close the window. After a few seconds, the virtual infrastructure client will shown the reconfiguration being complete.

Now logon to the operating system of the vm, as the root user - or use sudo.

You will see that the vm does not see the new disk, ie running the command:

fdisk -l

Shows only the existing disks, there is no sign of the new one.

What we need to do is, re-scan the SCSI bus, without rebooting the vm. To do this run the following command:

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

Where the # is replaced with the SCSI host value, usually 0

Now we re-run the command:

fdisk -l

We can now see our additional disk and can carry on configuring it using the usual tools, I.e. fdisk and mkfs or partitioner through yast, etc

8 comments:

  1. Thank you very much, I have been looking for something like that for ages !

    Works perfectly (do not forget the spaces between the dashes people!).

    ReplyDelete
  2. Nice! Worked for me. Reiterating that the dashes within quotes have a space between two dashes.

    ReplyDelete
  3. Fantastic time saver. Thanks!

    ReplyDelete
  4. Does NOT work for me. Tried multiple times with multiple hosts (0,1,2)

    ReplyDelete
  5. in the suse 12 this command not work...

    to solve my issue i run the command above:
    rescan-scsi-bus.sh --forcerescan

    ReplyDelete