How to create and start VirtualBox VM without GUI

Source: Internet
Author: User
Tags oracle vm virtualbox vm virtualbox rdesktop

Suppose want to create and run virtual machines (VMs) on VirtualBox. However, a host machine does not the support X11 environment, or your only has access to a terminal in a remote host machine. And how can I create and run VMs on such a host machine without VirtualBox GUI? This can is a common situation for servers where VMs is managed from remotely.

In fact, VirtualBox comes with a suite of command line utilities, and you can use the VirtualBox command line interfaces ( CLIs) to manage VMs on a remote headless server. In this tutorial, I'll show you how to create and start a VM without VirtualBox GUI.
Prerequisite for starting VirtualBox VM without GUI

First, you need to install VirtualBox Extension Pack. The Extension Pack is needed to run a Vrde Remote Desktop server used to access headless VMs. Its binary was available for free. To download and install VirtualBox Extension Pack:
$ wget Http://download.virtualbox.org/virtualbox/4.2.12/Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
$ sudo vboxmanage extpack install./oracle_vm_virtualbox_extension_pack-4.2.12-84980.vbox-extpack

Verify the Extension Pack is successfully installed, by using the following command.
$ vboxmanage List Extpacks

Extension packs:1
Pack No. 0:oracle VM VirtualBox Extension Pack
version:4.2.12
revision:84980
Edition:
DESCRIPTION:USB 2.0 Host Controller, VirtualBox RDP, PXE ROM with E1000 support.
Vrde MODULE:VBOXVRDP
Usable:true
Why unusable:

Create a VirtualBox VM from the command line

I assume that the VirtualBox ' VM directory was located in ' ~/virtualbox\ VMs '.

First create a VM. The name of the VM is ' TESTVM ' in this example.
$ vboxmanage createvm--basefolder/opt/vm--name "TESTVM"--register

Specify the hardware configurations of the VM (e.g., Ubuntu OS type, 1024MB memory, bridged networking, DVD booting).
$ vboxmanage MODIFYVM "TESTVM"--memory 1024x768--acpi on--boot1 DVD--nic1 bridged--bridgeadapter1 eth0--ostype Ubuntu

Create a disk image (with size of 10000 MB). Optionally, you can specify disk image format by using "--format [vdi| vmdk| VHD] "option. Without this option, VDI image format is used by default.
$ vboxmanage createvdi--filename ~/virtualbox\ VMS/TESTVM/TESTVM-DISK01.VDI--size 10000

ADD an IDE controller to the VM.
$ vboxmanage storagectl "TESTVM"--name "IDE Controller"--add IDE

Attach the previously created disk image as well as CD/DVD drive to the IDE controller. Ubuntu installation ISO image (found In/iso/ubuntu-12.04.1-server-i386.iso) is then inserted to the CD/DVD drive.
$ vboxmanage Storageattach "TESTVM"--storagectl "IDE Controller"--port 0--device 0--type HDD--medium ~/virtualbox\ VM S/testvm/testvm-disk01.vdi
$ vboxmanage Storageattach "TESTVM"--storagectl "IDE Controller"--port 1--device 0--type dvddrive--medium/iso/ubuntu -12.04.1-server-i386.iso
Start VirtualBox VM from the command line

Once A new VM is created, you can start the VM headless (i.e., without VirtualBox console GUI) as follows.
$ vboxheadless--STARTVM "TESTVM" &

The above command would launch the VM, as well as Vrde Remote Desktop server. The Remote Desktop server is a needed to access the headless VM ' s console.

By default, the Vrde server was listening on TCP port 3389. If you want to change the default port number, use "-e" option as follows.
$ vboxheadless--STARTVM "TESTVM"-E "tcp/ports=4444" &

If You don't need Remote Desktop support, launch a VMS with "--vrde off" option.
$ vboxheadless--STARTVM "TESTVM"--vrde off &

Connect to headless VirtualBox VM via Remote Desktop

Once A VM is launched with Remote Desktop support, you can access the VM's console via any Remote Desktop client (e.g., RD Esktop).

To install Rdesktop on Ubuntu or Debian:
$ sudo apt-get install Rdesktop

To install Rdesktop in CentOS, RHEL or Fedora, configure Repoforge on your system, and then run the following.
$ sudo yum install Rdesktop

To access a headless VMS on a remote host machine, run the following.
$ rdesktop-a <IP_address_host_machine>

If You use a custom port number for a Remote Desktop server, run the following instead.
$ rdesktop-a <IP_address_host_machine:port_number>

Once Rdesktop is successfully connected to the VMS via Remote Desktop, you'll see the initial installation screens.

How to create and start VirtualBox VM without GUI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.