Creating VM-s via CLI using VBoxManage

If you happen to setup virtual machines to remote server then you might not have good access to graphical interface to use the VirtualBox graphical interface but you have to be able to manage using CLI. This gives you even more flexibility but needs some time until you can figure out what and how to do.

First create virtualmachine and register it with virtualbox.

VBoxManage createvm --name myvirtmachine --register

Create harddisk for this virtualmachine

VBoxManage createhd --filename myvirtmachinedisk --size 100000

Set some useful params for tis virtual machine

VBoxManage modifyvm myvirtmachine--ostype Ubuntu_64 --memory 2048 --cpuhotplug on --cpus 2 --nic1 bridged --bridgeadapter1 eth0

Create storage controller for virtual machine

VBoxManage storagectl myvirtmachine --name myvirtmachinestoragectl --add sata

Attach installation media into DVD drive to this storage controller. In this case i have downloaded previously the ubuntu isntaller CD

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 0 --type dvddrive --medium ../ubuntu-12.04-server-amd64.iso

Attach HDD to this storage controller

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 1 --type hdd --medium myvirtmachinedisk.vdi

Now you are ready to start the VM. First command is without vnc access, another has vnc access and you can get the access to console by opening vnc session to host machine.

VBoxHeadless -startvm myvirtmachine --vrde off
VBoxHeadless -startvm myvirtmachine --vnc --vncpass 12345

Leave a Reply

Your email address will not be published.


*