How to attach a virtual hard disk using VBoxManage?
Solution 1:
I believe this should do it for a virtual hard drive.
VBoxManage modifyvm winxp-web-dev --hda "/home/vbox/.VirtualBox/HardDisks/my_new_disk.vdi"
(That is how I do it when I create vm's from the console)
Solution 2:
Pretty old question but here is how I do it:
VBoxManage storageattach my-vm-name \
--storagectl "SATA Controller" \
--device 0 \
--port 0 \
--type hdd \
--medium /path/to/my-new.vdi
This assumes you want to replace the old disk. If you want to want to just add another disk use another port, for example 1 if you have only 1 disk (on port 0). Please note you could also add disks (or cd/dvd images) to "IDE Controller".
Solution 3:
You need first add de contoller on your vm machine:
vboxmanage storagectl YourVMNameOrID --name "SATA Controller" --add sata --controller IntelAHCI --portcount 1 --bootable on
and then attach the virtual disk image to the storage controller:
vboxmanage storageattach YourVMNameOrID --storagectl "SATA Controller" --device 0 --port 0 --type hdd --medium YourVirtualDiskImage.vdi