Skip to content

Instantly share code, notes, and snippets.

@gleicon
Created April 24, 2010 15:25
Show Gist options
  • Save gleicon/377708 to your computer and use it in GitHub Desktop.
Save gleicon/377708 to your computer and use it in GitHub Desktop.
#!/bin/bash
# author Gleicon Moraes
# q&d for provisioning VirtualBox images for a Hadoop project
# works on Mac Os X Snow Leopard.
# fill in for the ubuntu iso path (must be absolute or put it on VBox HDD dir)
#
if [ "$#" -lt 1 ]; then
echo "use as createvm <VMName>"
exit
fi
export VMHDD="~/Library/VirtualBox/HardDisks/$1.vdi"
export ISOIMG="path/to/ubuntu-9.10-server-i386.iso"
VBoxManage createvm -name $1 -register
VBoxManage storagectl $1 --name "IDE Controller" --add ide --controller PIIX4
VBoxManage createhd --filename $VMHDD --size 4096 --variant Standard
VBoxManage storageattach $1 --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium $VMHDD
VBoxManage storageattach $1 --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium $ISOIMG
VBoxManage modifyvm $1 --memory "256"
VBoxManage modifyvm $1 --name $1
VBoxManage modifyvm $1 --ostype Ubuntu
VBoxManage modifyvm $1 --usb on
VBoxManage modifyvm $1 --nic1 bridged --bridgeadapter1 "en1: AirPort"
echo "Start VM and configure it using rdesktop (or CoRD on mac): VBoxHeadless --startvm $1 &"
echo "Start VM and use it: VBoxHeadless --startvm $1 --vrdp=off &"
echo "PowerOff VBoxManage: controlvm $1 poweroff"
echo "Suspend and save state: VBoxManage controlvm $1 savestate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment