I have 22-VirtualBox VM's installed consuming about 80-GB Hard Disk space of available 100-Gb Linux install partition. New hard-drive has been installed, partition created, and df -h shows my partitions just as I want it.
Now, I want to move some VM's over.
In this tutorial, I will detail how to move a VirtualBox VM into another partition. Im running Debian9-Stretch with VirtualBox 5.1.22 r115126 (QT5.7.1).
For this tutorial, I will be using a VM I created for TurnkeyLinux Virtual Appliance FileServer. If you have never heard of Turnkey Linux, they are a bunch of guys creating a Virtual Appliance Library of Debian server software appliances.
Check them out: https://www.turnkeylinux.org/
TUTORIAL BEGIN
1) Ensure that the VM to be moved is powered off.
2) Select / Right-click on the VM to be moved,
- click settings
- click on the storage item
- click on the vdi file(for the hard disk utilized by the VM)
- click 'remove attachment' (bottom button)
- click OK.
before removal of my vm .vdi file
after removal of my VM .vdi file
3) With the VM still selected,
- click on File menu
- click Virtual Media Manager
- in the Virtual Media Manager window, look for the vdi file of your VM to be removed, select it and click remove
- click remove,
- click close
You will be prompted to remove the virtual hard disk, click remove.
On the next screen, you get prompted if you want to delete the storage unit of the virtual hard disk. We dont want to delete the storage unit since we would later link the virtual hard disk back to it. Click 'keep'
4) Now lets copy the VM to the new hard-drive / partition.
- I copied the particular-VM folder to a new location, and renamed the old folder - for backup purposes.
5) Back to VirtualBox, select the VM,
- go to the storage item
- click on the '(+) Add Hard disk' button besides 'Controller...'
You will be propted to create a new disk or use an existing one. Since we want to use the one we copied, click 'choose existing disk'.
- then locate the vdi file you copied into a new location.
- click 'open' to add it
- click ok.
Once added, boot your VM.
If all goes well, remove the old VM from the old location to free up more space.