Thursday, March 24, 2011

How to install a virtual machine in VirtualBox headlessly

Sure I know there are plenty of documentations and how-to's about this.  But this is my blog and this is where I log what I want for myself : )

Starting by installing an extension pack for VRDP support:

To create a virtual machine, follow these steps:
  • Register a VM: VBoxManage createvm --name "miyabi" --ostype Windows2003 --register
  • Setting RAM, boot device: VBoxManage modifyvm "miyabi" --memory 1024 --acpi on --boot1 dvd
  • Settings bridged mode networking: VBoxManage modifyvm "miyabi" --nic1 bridged --bridgeadapter1 eth0
  • Create a virtual harddisk (in this case 60GB in size):  VBoxManage createhd --filename "miyabi.vdi" --size 60000
  • Add an IDE Controller to the new VM: VBoxManage storagectl "miyabi" --name "IDE Controller" --add ide --controller PIIX4
  • Set the VDI file created above as the first virtual hard disk of the new VM: VBoxManage storageattach "miyabi" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "miyabi.vdi"
  • Attach the ISO file that contains the operating system installation that you want to install later to the virtual machine, so the machine can boot from it (use --medium emptydrive to detach the iso): VBoxManage storageattach "miyabi" --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium /full/path/to/win2003.iso
  • As root, run:  /etc/init.d/vboxdrv setup
  • If you find error, you may want to try this: insmod /lib/modules/2.6.33-grml/updates/dkms/vboxnetflt.ko
  • I put the command above to my /etc/rc.local .
Useful commands:
  • To start a vm: VBoxHeadless --startvm
  • To get a list of valid ostypes: VBoxManage list ostypes


Post a Comment