Headless VirtualBox

Running a VirtualBox server without a monitor or keyboard attached to it.

Creating a VM
http://www.virtualbox.org/manual/ch07.html#id2533145
Create the initial VM:

VBoxManage createvm --name "<VM Name>" --ostype "Linux" --register

CentOS 6.2 required PAE to be on:

VBoxManage modifyvm "<VM Name> --pae on

Adjust the NIC configuration - second command lets you set a custom MAC address to for the network interface:

VBoxManage modifyvm "<VM Name>" --nic1 bridged --bridgeadapter1 enp8s0f0
VBoxManage modifyvm "<VM Name> --macaddress1 080027268E94

Adjust the amount of RAM:

VBoxManage modifyvm "<VM Name>" --memory 512

Remove the audio:

VBoxManage modifyvm "<VM Name>" --audio none

Hard Disk

  • Add an IDE controller for the hard disk:
    VBoxManage storagectl "<VM Name>" --name "IDE Controller" --add ide --controller PIIX4
  • Create a drive, 5GB in this example:
    VBoxManage createvdi -filename ~/.VirtualBox/HardDisks/<diskname>.vdi -size 5000 -register
  • Add the drive to the VM:
    VBoxManage modifyvm "<VM Name>" --hda "<diskname>.vdi"

    or

    VBoxManage storageattach "<VM Name>" --storagectl "IDE Controller" --port 0 --device 0 \
    --type hdd --medium ~/.VirtualBox/HardDisks/<diskname>.vdi

    Detach a drive:

    VBoxManage storageattach "<VM Name>" --storagectl "IDE Controller" --port 0 --device 0 \
    --type hdd --medium none

Running a VM "headless"

  • Starting a headless VM:
    VBoxHeadless --startvm <vmname> &
  • Stopping a headless VM:
    VBoxManage controlvm <vmname> pause|resume|reset|poweroff|savestate

Boot DVD
Register the DVD ISO file:

VBoxManage registerimage dvd /extra/CentOS-6.2-i386-minimal.iso

or

VBoxManage storageattach  "<VM Name>" --storagectl "IDE Controller" --port 1 --device 0 \
--type dvddrive --medium /extra/CentOS-6.2-i386-minimal.iso

Clone a VM

VBoxManage clonehd <vmname> <outputfile>

Remote Display (VRDP)
Specify a port for VRDP access, and then turn it on:

VBoxManage modifyvm "<VM Name>" --vrdeport <port number>
VBoxManage modifyvm "<VM Name>" --vrde on

Links
Secrets for controlling VirtualBox from the command line

Recent Updates

  • 8 months 3 weeks ago
    1.27.2 update
  • 9 months 4 days ago
    Drupal 10/11 config
  • 9 months 6 days ago
  • PHP
    9 months 6 days ago
    PHP 8.3.11 and AlmaLinux
  • 9 months 6 days ago
    New version of Pound