How to create a VirtualBox VM on an Ubuntu server from scratch.

apt-get upgrade virtualbox
VBoxManage createvm --name foo --ostype Ubuntu_64 --register

# configure it to use bridge networking
VBoxManage modifyvm foo --memory 2048 --cpus 2 --pae on --acpi on --hpet on --ioapic on --hwvirtex on --vtxvpid on --accelerate3d off --audio none --chipset ich9 --nic1 bridged --bridgeadapter1 eth0 --vrde on --vrdeport 5555 --clipboard bidirectional --vrdeaddress <server ip addr>

# create and attach a 10G virtual disk
VBoxManage createhd --filename VirtualBox\ VMs/storage/bar.vdi --size 10240
VBoxManage storagectl foo --name foo --add sata --controller IntelAHCI --bootable on
VBoxManage storageattach foo --storagectl foo --port 0 --device 0 --type hdd --medium ~/VirtualBox\ VMs/storage/bar.vdi

# configure to boot from the install image
VBoxManage storagectl foo --name dvd --add ide --bootable on
VBoxManage storageattach foo --storagectl dvd --port 0 --device 0 --medium /tmp/ubuntu-16.04.4-server-amd64.iso --type dvddrive
VBoxManage modifyvm foo --boot1 dvd

# start
VBoxHeadless -s foo

# now go to any computer, vnc into the new virtual machine and finish the installation:
# vnc <server ip addr>:5555

# stop the VM and diconnect the DVD image
VBoxManage controlvm foo poweroff
VBoxManage storageattach foo --storagectl dvd --port 0 --device 0 --medium none
VBoxManage modifyvm foo --boot1 disk

# start it again, vnc in, configure the ssh access and power off
# from now on, always start with vnc disabled, and use ssh to log in:
nohup VBoxHeadless -s foo --vrde off&
Tags:

December 2025

S M T W T F S
 12345 6
7 8910111213
14151617181920
21222324252627
28293031   

Expand Cut Tags

No cut tags

Style Credit