Create VirtualBox Guest Machines on Ubuntu 16.04 LTS Server (Headless)

Power users can run VirtualBox host software on headless Ubuntu 16.04 LTS servers and create virtual guest machines easily from remote locations… this allows you to run VirtualBox from anywhere without connecting directly to the host servers..

Few days ago we showed students and new users how to install and use VirtualBox virtualization software on Ubuntu 16.04 LTS server.. This can also known as headless installation.

Headless installation is when you installed and run VirtualBox on a server without direct monitor or desktop environment via remote terminal. The GUI-less installation of VirtualBox is typical in server environments.

This brief tutorial is going to show you how to install and guest operating systems on the headless installation of VirtualBox. This should be quick and easy new students should love it.

To get started with installing a guest OS on a headless VirtualBox follow the guide below:

Step 1: Install VirtualBox on Ubuntu server

Before installing a guest OS on VirtualBox, you must first have the host server installed. Our previous post showed you how.. click the link below to read this post.

VirtualBox 5.2 on Ubuntu 16.04 LTS Server (Headless)

Step 2: Create a Virtual Machine

Now that you’ve installed VirtualBox on the host computer.. go and install your first guest operating systems. For this post, we’ll going to install Ubuntu 16.04 server as our first guest machine.

To create a VirtualBox guest machine called Ubuntu_1604, follow the guide below.

First create a location to store all the guest machines and configuration files. Run the commands below to create a folder in the /var directory called vbox.

sudo mkdir -p /var/vbox

Then run the commands below to create your first guest machine named Ubuntu_1604 and store the configurations in /var/vbox

sudo VBoxManage createvm --name Ubuntu_1604 --ostype Ubuntu_64 --register --basefolder /var/vbox

After running the commands above, run the commands below to view information about the guest OS you just created.

sudo VBoxManage showvminfo Ubuntu_1604

You should see something like the content below:

Name: Ubuntu_1604
Groups: /
Guest OS: Ubuntu (64-bit)
UUID: 7ff8048e-b6d8-49ca-b21a-ad0fc04ba6d3
Config file: /var/vbox/Ubuntu_1710/Ubuntu_1604.vbox
Snapshot folder: /var/vbox/Ubuntu_1604/Snapshots
Log folder: /var/vbox/Ubuntu_1604/Logs
Hardware UUID: 7ff8048e-b6d8-49ca-b21a-ad0fc04ba6d3
Memory size: 128MB
Page Fusion: off
VRAM size: 8MB
CPU exec cap: 100%
-------------
-------------

Step 3: Modify the Guest Machine

Next, modify the guest os to increase the system memory, include a virtual dvd drive and well as enable VRDP (Virtual Remote Desktop Protocol) to access the guest machine remotely by running the commands below.

sudo VBoxManage modifyvm Ubuntu_1604 --memory 1024 --boot1 dvd --vrde on --vrdeport 5001

Add a network adapter and NAT it by running the commands below. If you want it to be bridged, change nat to bridged.

sudo VBoxManage modifyvm Ubuntu_1604 --nic1 nat

Next, create a storage sata controller named “Ubuntu_1604_SATA

sudo VBoxManage storagectl Ubuntu_1604 --name "Ubuntu_1604_SATA" --add sata

Next, create virtual HDD with 10GB size and format it as VDI with standard variant.

sudo VBoxManage createhd --filename /var/box/Ubuntu_1604.vdi --size 10280 --format VDI --variant Standard

Step 4: Attach the Virtual Hard Disk

Next, attach the virtual hard disk created above to the VM… To do that run the commands below:

sudo VBoxManage storageattach Ubuntu_1604 –-storagectl Ubuntu_1604_SATA –-port 1 –-type hdd –-medium /var/box/Ubuntu_1604.vdi

Step 5: Attach the Ubuntu ISO Image

Next, attach the download operating system ISO file to the VM by running the commands below.

sudo VBoxManage storageattach Ubuntu_1604 --storagectl Ubuntu_1604_SATA --port 0 --type dvddrive --medium /tmp/ubuntu-16.04-server-amd64.iso

Now when you run the showvminfo commands, you should see the new guest machine config settings.

Name: Ubuntu_1604
Groups: /
Guest OS: Ubuntu (64-bit)
UUID: 7ff8048e-b6d8-49ca-b21a-ad0fc04ba6d3
Config file: /var/vbox/Ubuntu_1604/Ubuntu_1604.vbox
Snapshot folder: /var/vbox/Ubuntu_1604/Snapshots
Log folder: /var/vbox/Ubuntu_1604/Logs
Hardware UUID: 7ff8048e-b6d8-49ca-b21a-ad0fc04ba6d3
Memory size: 1024MB
Page Fusion: off
VRAM size: 8MB
CPU exec cap: 100%
HPET: off
Chipset: piix3
Firmware: BIOS
Number of CPUs: 1
PAE: on
Long Mode: on
Triple Fault Reset: off

Step 6: Start the Guest Machine

Now that everything is ready, run the commands below to start the guest machine.

sudo VBoxManage startvm Ubuntu_1604 --type headless

You should see the message that the machine has started

Waiting for VM "Ubuntu_1604" to power on...
VM "Ubuntu_1710" has been successfully started.

Now open open Remote Desktop Connection on your Windows machine and connect to the server IP followed by the port 5001

ubuntu virtualbox headless

You should be able to install the guest machine remotely via RDP.

virtualbox headless ubuntu

Enjoy!

You may also like the post below:

Install Drupal CMS on Ubuntu 16.04 LTS with Apache2, MariaDB, PHP 7.1 and Let’s Encrypt SSL/TLS

8 Replies to “Create VirtualBox Guest Machines on Ubuntu 16.04 LTS Server (Headless)

  1. Wonderful wonderful article. I am yet to install magento 2.1 in Ubuntu but I have done it in cnet os 7 and steps are more or same. Thanks a for such a lovely step by step article

  2. I would like to install Win7 on my Ubuntu 16.04 server and access with Mint client using RDP, have you tried that? My goal is to have access to Win7 that is installed on a stable system instead of my laptop which needs to be refreshed now and then.

  3. Thanks for the post but i come accross with this error “VBoxManage: error: Invalid parameter ‘–-storagectl’ “.., what could be the problem??

      1. sudo VBoxManage storageattach Ubuntu_1604 –storagectl Ubuntu_1604_SATA –port 1 –type hdd –medium /var/box/Ubuntu_1604.vdi

    1. It will be –storageectl. Rather that copying directly from website , use your keyboard “-” sign two times.

  4. It’s because

    ‘–-storagectl’ “.., what could be the problem??

    The content creator may of have a typeo. The correct is “–” not whatever he has. Replace that with — and you will be good to go. Confirmed this on my side. Had same issue and noticed that typeo.

  5. Hi,
    Thank you very much for this wonderful step by step. For my case, the server is running CentOS. My question is, how do I know that I am inside the guest machine? I want to install software in the guest machine. For my case, I installed Ubuntu 18.04 as a guest machine. And how can I transfer the file from host machine to guest machine? Could you please also show here, how do I set the host-only adapter IP and DHCP server IP? I want to set the IP 192.168.56.1/24 and DHCP server IP is 192.168.56.100/24 , range 192.168.56.101-254

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.