Skip to content

Instantly share code, notes, and snippets.

@stucchio
Created December 16, 2010 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stucchio/743418 to your computer and use it in GitHub Desktop.
Save stucchio/743418 to your computer and use it in GitHub Desktop.
Clone a Virtualbox VM
#!/bin/sh
old=$1
new=$2
if [ $old ] && [ $new ]
then
echo "Cloning $old, saving result as $new"
else
echo "Usage: clone-ubuntu.sh oldname newname"
fi
VBoxManage clonehd $old.vdi $new.vdi --remember
echo Hard drive cloned from $old.vdi to $new.vdi
VBoxManage createvm --name $new --ostype Ubuntu --register
echo New VM $new created.
VBoxManage storagectl $new --name "IDE Controller" --add ide
VBoxManage storageattach $new --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium $new.vdi
echo Storaged medium attached.
VBoxManage modifyvm $new --nic1 bridged --bridgeadapter1 re0
echo Networking turned on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment