The organisation for which I work, and specifically the department in which I work, has some pretty serious funding problems. So problematic that in 2015 I bought two 27" monitors out of my own pocket to replace the two 19" monitors I had in the office. Later that year my monitor for my desktop at home died so I brought them home for a while. A few weeks ago I got tired of using the 19" again so I took the 27s back to work. That's left me with a desktop system at home that doesn't have any monitors and me wondering how best to use it.
Enter my comments about filling the hard drives in my laptops with virtual machine images! Since I have a machine with no monitors, I'm kind of curious about running VirtualBox "headless". It's certainly not as convenient as running the VMs locally but the hardware is available. I also have an entire shrimp, andouille and bleu cheese pizza, a few cans of Diet Coke and an otherwise free Saturday night so why not give it a shot?
Installing on Ubuntu 16.04.1 LTS
Since I use macOS at work and macOS and Windows 10 at home, I haven't installed VirtualBox on Linux in a while - in a very long while, as a matter of fact, since I've primarily used OS X (and now macOS Sierra) as my desktop OS since right after Snow Leopard came out.
VirtualBox has full download/installation instructions for Linux available at:
https://www.virtualbox.org/wiki/Linux_Downloads
Since he box I have available is already running Ubuntu 16.04 LTS, I followed the instructions for Debian-based distributions.
Note: because the system doesn't have monitors, I'm going to do everything over either SSH or VRDE, the VirtualBox Remote Desktop Extension, which is basically RDP.
First, add the VirtualBox repository to apt:
echo 'deb http://download.virtualbox.org/virtualbox/debian xenial contrib' | sudo tee -a /etc/apt/sources.list.d/virtualbox.list
Download and add the Oracle public key for apt:
wget https://www.virtualbox.org/download/oracle_vbox_2016.asc
sudo apt-key add oracle_vbox_2016.asc
Then synch the package index files from the apt sources and install the latest version of VirtualBox:
sudo apt-get update
sudo apt-get install dkms virtualbox-5.1
NOTE!! You can't interact with VirtualBox over VRDE until after you've installed the extension pack *as root*. You can download it with (one line):
wget http://download.virtualbox.org/virtualbox/5.1.14/Oracle_VM_VirtualBox_Extension_Pack-5.1.14-112924.vbox-extpack
And then install it with (one line):
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.1.14-112924.vbox-extpack
Unless something has gone terribly wrong, it should be a fairly quick and painless process!
Creating My First VM
The first VM I want to add is FreeBSD - it's a light install and the only install I've done so far that's quicker is OpenBSD. First, download the ISO (one line):
wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/ISO-IMAGES/11.0/FreeBSD-11.0-RELEASE-amd64-disc1.iso
Then create a new VM configuration with VBoxManage:
VBoxManage createvm --name "FBSD Test" --ostype FreeBSD_64 --register
I think a 5GB hard drive is much more than enough for a simple install but I'm going to add a 5GB disk, just in case:
VBoxManage createhd --filename "FBSD_Test.vdi" --size 5000
Live CDs and DVDs are usually treated as IDE devices so I'm going to add an IDE controller (one line):
VBoxManage storagectl "FBSD Test" --name "IDE Controller" --add ide --controller PIIX4
Attach the 5GB hard drive from above to the VM (one line):
VBoxManage storageattach "FBSD Test" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium FBSD_Test.vdi
Attach the FreeBSD CD to the VM (one line):
VBoxManage storageattach "FBSD Test" --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium FreeBSD-11.0-RELEASE-amd64-disc1.iso
Make sure VRDE is enabled in the configuration:
VBoxManage modifyvm "FBSD Test" --vrde on
Then start the VM:
VBoxManage startvm "FBSD Test" --type headless
If everything has gone correctly, you should see a message similar to:
VM "FBSD Test" has been successfully started.
The entire process should look something like this. Notice I've split the long lines with " \ ", an operator in Unix and Linux that lets you split long commands across multiple lines - in this case, I've done it for visibility purposes so that each section is easier to read.
But do I have a proper running VM that's waiting to have FreeBSD installed from the ISO to a 5GB disk?
Remote Desktop
When I had a Linux (or FreeBSD) desktop, I used rdesktop to RDP to Windows hosts:
http://www.rdesktop.org/
On OS X (and now macOS), I prefer the actual Microsoft Remote Desktop client available from iTunes:
https://itunes.apple.com/us/app/microsoft-remote-desktop/id715768417?mt=12
The configuration for a new connection is fairly straight-forward, all you really need to provide are a connection name and PC name (this can be a FQDN, an IP address or an AD name). Note that VRDE uses the local PAM authentication on Linux so the username and password should be that of the user running VirtualBox:
Once I started the session I saw the FreeBSD install menu - at least a partial success!
I enabled scaling and then repositioned the window a little to get a better view:
To save you having to deal with screenshots up through the installation, I'll give a quick spoiler: it works!
NOTE: After the install completes, you may have to perform the equivalent of manually ejecting and removing a CD/DVD image. Despite rational convention, there is a storageattach function but no storagedetach - instead, you have to attach an empty drive. In this scenario I used "IDE Controller port 0 device 1" as my CD/DVD drive where I attached the FreeBSD ISO so now I need to detach it by attaching an "emptydrive":
VBoxManage storageattach "FBSD Test" --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium emptydrive
Summary
VirtualBox is really intended for personal use on the desktop and competes most closely with VMWare's Workstation/Fusion, Parallels and Microsoft's Hyper-V (don't be misled by that statement, Hyper-V certainly has a place in production virtualisation environments). If you need to run production virtual machines on a dedicated VM server there are multiple solutions available.
VMWare makes ESXi available for free:
http://www.vmware.com/products/vsphere-hypervisor.html
If you're in a Linux environment you can base your VMs on KVM or Virtuozzo with OpenVZ:
http://www.linux-kvm.org/page/Main_Pagehttps://openvz.org/Main_Page
Or, if you like Amazon's AWS, you can use Xen:
https://www.xenproject.org/users/getting-started.html
As mentioned, there's also Hyper-V:
https://www.microsoft.com/en-us/cloud-platform/server-virtualizationhttps://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
That doesn't mean you HAVE to run VirtualBox locally, though - they have a complete command set available to do interesting things with virtual machine using VBoxManage that gives you a lot of power when coupled with access tools like SSH.
In truth I may never use it again - this is the first time in many years of using VirtualBox that I've done anything with a headless setup - but if nothing else it was an interesting way to spend a Saturday night!
No comments:
Post a Comment
Note: only a member of this blog may post a comment.