Sometimes you need to test stuff on another operating system.
Then a VirtualBox is a good solution,
It makes a virtual machine on your machine that you can run a different operating system on.
But this takes a lot of space on your hard drive, and maybe there are more people that need to use it as well, then they will need to install in on their computer as well.
Or you have a license for a special program that only will work on one computer.
If you then have a headless server you can install it on that server and use remote desktop to login to that operating system.
Step 1: Update Ubuntu
Before installing VirtualBox, run the commands below to update the Ubuntu server.
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
Step 2: Install Required Linux Headers
Now that your system is updated, run the commands below to install required Ubuntu linux headers.
sudo apt-get -y install gcc make linux-headers-$(uname -r) dkms
Step 3: Add VirtualBox Repository and key
After installing the required package above, run the commands below to install VirtualBox repository key.
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
Next run the commands below to add VirtualBox repository to your system.
sudo sh -c 'echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list'
Step 4: Install VirtualBox
After adding the repository and key, run the commands below to install VirtualBox 6.0. At the time of this writing the latest version of the software was 6.0. If there are newer versions available, please replace the 2 below with the current latest.
sudo apt-get update sudo apt-get install virtualbox-6.0
To verify if VirtualBox is installed, run the commands below.
VBoxManage -v
Step 5: Install VirtualBox Extension Pack
Everytime you install VirtualBox make sure to install the extension pack as well. The pack enables VRDP (Virtual Remote Desktop Protocol) and many other enhancements.
To install it, run the commands below
curl -O https://download.virtualbox.org/virtualbox/6.0.8/Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.0.8.vbox-extpack
Agree to the terms and install.
Run the commands below to view the extension pack installed.
VBoxManage list extpacks
The results should look like the one below:
jaime@digitalconcept:~$ VBoxManage list extpacks Extension Packs: 1 Pack no. 0: Oracle VM VirtualBox Extension Pack Version: 6.0.8 Revision: 119785 Edition: Description: USB 2.0 and USB 3.0 Host Controller, Host Webcam, VirtualBox RDP, PXE ROM, Disk Encryption, NVMe. VRDE Module: VBoxVRDP Usable: true Why unusable:
Step 6: 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 7: 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 8: 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 9: 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 10: 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

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

Be First to Comment