Skip to content

Instantly share code, notes, and snippets.

@jgcasta
Created June 14, 2014 10:58
Show Gist options
  • Save jgcasta/03b643ecb6dc596d00bb to your computer and use it in GitHub Desktop.
Save jgcasta/03b643ecb6dc596d00bb to your computer and use it in GitHub Desktop.
Shell script to create a VirtualBox Virtual machine
#!/bin/bash
#
# createvm.sh
#
# ver 1.0
#
# Jose Gomez Castaño jgcasta@gmail.com
#
# Create a Virtual Box Machine in the createPath directory with the name given in name variable.
# Operating Sistem has to be specified in os variable and ISO has to be accesible in isoPath
# When created, the name virtual machine can be accesible via RDP at localIP:3389
# The UUID and Setting file is returned
#
# Usage: $./createvm.sh
#
name='XP_pepe'
os='WindowsXP'
sizeDisk=10000
isoPath='/home/pepe/virtualbox/wxp_sp2.ISO'
createPath='/home/pepe/virtualbox/'
VBoxManage createhd --filename $createPath$name'/'$name.vdi --size $sizeDisk
VBoxManage createvm --basefolder $createPath --name $name --ostype $os --register
VBoxManage storagectl $name --name "IDE Controller" --add ide
VBoxManage storageattach $name --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium $isoPath
VBoxManage storagectl $name --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $name --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $createPath$name'/'$name.vdi
VBoxManage modifyvm $name --boot1 dvd --boot2 disk --boot3 none --boot4 none
VBoxManage modifyvm $name --memory 1024 --vram 128
VBoxManage modifyvm $name --nic1 bridged --bridgeadapter1 eth0
VBoxHeadless -s $name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment