Clone a VirtualBox VDI using VBoxManage on the command line
20 Dec 2010I run into this situation all the time. I want to try out a new software (usually it’s a database of somesort) and I want to try it on a clean server installation. I don’t want to mess up my client or an existing server or have to install the OS fresh each time, so I turn to VirtualBox cloning via the command line.
Let’s spec out what we want the script to do:
- Clone a clean install VDI that exists in a known location (typically ~/.VirtualBox/HardDisks/)
- Create a new virtual machine
- Attach the new VDI to that machine
- Setup a standard configuration for boot order, bridged networking etc
- Fire up the instance
Here is the final script. Note it includes a param to set the name of the new machine (not tested with spaces in the name yet). Note also, I have set my network to use wlan0. You might want to use a different network adapter.