I need to have virtual machines in servers without GUI. In this case I must configure virtual machines only with VBoxManage utility.
In first step i make/install MV under GUI version of VirtualBox and after that copy on guest server.
After that we need to register virtual machine.
vboxmanage registervm /path-to/vbox file
and start
VBoxManage startvm "Test" --type headless
When we need to shutdown virtual machine:
VBoxManage controlvm "Test" acpipowerbutton
or
VBoxManage controlvm "Test" poweroff
To view some information about virtual machine:
vboxmanage showvminfo /opt/vm/Test/Test.vbox
When we need to modify number of CPU. Stop virtual machine and afler that:
VBoxManage modifyvm "Test" --cpuhotplug on
VBoxManage modifyvm "Test" --cpus 4
To modify memory:
VBoxManage modifyvm "Test" --memory 4096
To delete network interface:
VBoxManage modifyvm "fbsd" --nic1 none
To add bridged interface:
VBoxManage modifyvm fbsd --nic1 bridged --bridgeadapter1 em1
To modify IP address
only if you have vboxguestadditions installed
# VBoxManage guestproperty get "Test" "/VirtualBox/GuestInfo/Net/0/V4/IP"
No value set!
# VBoxManage guestproperty set "Test" "/VirtualBox/GuestInfo/Net/0/V4/IP" 192.168.101.215
# VBoxManage guestproperty get "Test" "/VirtualBox/GuestInfo/Net/0/V4/IP"
Value: 192.168.101.215
# VBoxManage guestproperty get "Test" "/VirtualBox/GuestInfo/Net/0/V4/Netmask"
No value set!
# VBoxManage guestproperty set "Test" "/VirtualBox/GuestInfo/Net/0/V4/Netmask" 255.255.255.0
# VBoxManage guestproperty get "Test" "/VirtualBox/GuestInfo/Net/0/V4/Netmask"
Value: 255.255.255.0
# VBoxManage guestproperty get "Test" "/VirtualBox/GuestInfo/Net/0/V4/Gateway"
No value set!8
# VBoxManage guestproperty set "Test" "/VirtualBox/GuestInfo/Net/0/V4/Gateway" 192.168.101.1
To add virtual machine in bridge with network interfcace:
VBoxManage controlvm "Test" nic1 bridged em1
When we have this error:
==================
Waiting for VM "Test" to power on... VBoxManage: error: VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole
===================
must enable Virtualisation Technology in BIOS.
To view all os types supported by VBoxManasge
VBoxManage list ostypes (guest)
A short example: VBoxManage modifyvm "vm" --ostype Linux24_64
If you have following error:
This kernel requires an x86-64 CPU, but only detected an i686 CPU. Unable to boot – please use a kernel appropriate for your CPU
Just enable:
VBoxManage modifyvm "vm" --longmode on
To make a screenshot via console:
VBoxManage controlvm "vm" screenshotpng screen-shot-dev-006.png
Other posibile problems:
If you have:
# VBoxManage startvm "vm"
VBoxManage: error: Invalid frontend name: 'GUI/Qt'
can try
vboxmanage startvm vm --type headless
Waiting for VM "vm" to power on...
or if you have
vboxmanage startvm vm --type headless
Waiting for VM "vm" to power on...
VBoxManage: error: Failed to open/create the internal network 'HostInterfaceNetworking-bce0' (VERR_SUPDRV_COMPONENT_NOT_FOUND).
VBoxManage: error: Failed to attach the network LUN (VERR_SUPDRV_COMPONENT_NOT_FOUND)
you can try:
load module vboxnetflt
In my case:
kldload vboxnetflt
root@# kldstat
Id Refs Address Size Name
1 14 0xffffffff80200000 17bc680 kernel
2 2 0xffffffff819bd000 7b9a8 vboxdrv.ko
3 1 0xffffffff81c11000 29d86 vboxguest.ko
4 1 0xffffffff81c3b000 358d ums.ko
5 1 0xffffffff81c3f000 2a02 vboxnetflt.ko
6 2 0xffffffff81c42000 ba02 netgraph.ko
7 1 0xffffffff81c4e000 4123 ng_ether.ko
root@# vboxmanage startvm vm --type headless
Waiting for VM "vm" to power on...
VM "vm" has been successfully started.
root@#
Mapping Ports
VBoxManage setextradata "vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
If you install phpVirtualBox and have problems with login steps you can try to start virtualserver manually in verbose mode.
vboxwebsrv -v
If you have error VBOX_E_INVALID_VM_STATE
you can try: VBoxManage startvm "vm" --type emergencystop
and start the virtual machine again.