How to add a new SATA disk to a running VirtualBox guest

virtualbox

I installed a Centos7, booted it and want to add a new SATA disk online, but the "storage" part is grey. Other VirtualBox version supports it or is it fully not possible to add a new local disk for a running VM?

I don't want to power it off/on just because to add a new disk.

Best Answer

You can, in fact, hot-add storage to a running VirtualBox VM, using VBoxManage storageattach:

VBoxManage storageattach <VM Name> \
  --storagectl <Controller Name> \
  --port <Port Number> \
  --device <Device Number> \
  --type hdd \
  --medium <Path to Disk Image>

(Please note that on Windows you may have to remove the backslashes and line breaks.)

If you have a SATA controller, the device number is always 0 and the entire parameter is optional.

If the VM name has spaces, enclose them in quotes. Same goes for the storage controller name and image path.

There are important preconditions, (check with VBoxManage showvminfo):

  • A hot-plug-capable controller must exist (like SATA, SCSI, SAS)
  • The storage controller must have unused ports or you’ll have to replace a disk
    • By default, the VirtualBox GUI allocates only as many ports as required, so a free port is most likely not available
  • The operating system running inside the VM must support hot-plugging disks

IIRC the GUI does not offer support for any of this.

Related Question