WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: VirtualBox Cheatsheet / Machine Creation script  (Read 2421 times)

Offline mocore

  • Sr. Member
  • ****
  • Posts: 253
  • ~.~
VirtualBox Cheatsheet / Machine Creation script
« on: May 14, 2012, 07:22:17 AM »
 just thought id share this link i found  on  vbox / vboxmanage scriptings


Code: [Select]
# halfdog.net/Misc/TipsAndTricks/VirtualBox.html
mkdir -p -- "${_setup_vboxDir}"
# Select instance type, see VBoxManage list ostypes
# Does not work with newer vbox? Use --basefolder [dir]
vboxmanage createvm --name "${_setup_vboxName}" --ostype Ubuntu --basefolder "${_setup_vboxDir}/.."
mv -i -- "${_setup_vboxDir}/${_setup_vboxName}.vbox" "${_setup_vboxDir}/Instance.xml" < /dev/null
# On older vbox variants (lucid and before) the --settingsfile was working,
# the two lines from above could be replaced by
# vboxmanage createvm --name "${_setup_vboxName}" --ostype Ubuntu --settingsfile "${_setup_vboxDir}/Instance.xml"
vboxmanage registervm "${_setup_vboxDir}/Instance.xml"
# Remove macaddress1 if autogenerated mac is sufficient
vboxmanage modifyvm "${_setup_vboxName}" --memory 256 --rtcuseutc on --nic1 hostonly --nictype1 Am79C973 --macaddress1 00505605xxxx --hostonlyadapter1 vboxnet0
vboxmanage modifyvm "${_setup_vboxName}" --audio alsa --audiocontroller ac97

vboxmanage storagectl "${_setup_vboxName}" --name LsiLogic --add scsi --controller LsiLogic
vboxmanage createhd --filename "${_setup_vboxDir}/Root.vdi" --format VDI --size 4096
vboxmanage storageattach "${_setup_vboxName}" --storagectl LsiLogic --port 0 --device 0 --type hdd --medium "${_setup_vboxDir}/Root.vdi"

# Add a distinct swap disk, that can be reset or ignored in backups
vboxmanage createhd --filename "${_setup_vboxDir}/Swap.vdi" --format VDI --size 512
vboxmanage storageattach "${_setup_vboxName}" --storagectl LsiLogic --port 1 --device 0 --type hdd --medium "${_setup_vboxDir}/Swap.vdi"

# Add a cdrom drive
vboxmanage storagectl "${_setup_vboxName}" --name PIIX4 --add ide --controller PIIX4
vboxmanage storageattach "${_setup_vboxName}" --storagectl PIIX4 --port 0 --device 0 --type dvddrive --medium "${HOME}/PathToSetupMedium.iso"

# Add usb if needed
vboxmanage modifyvm "${_setup_vboxName}" --usb on --usbehci on