Virtualization is almost as old as our beloved integrated silicon chips.
At the beginning of the 1960s, there had been two major computing issues.
First, many individual mainframe models were bespoke, so incompatible.
The other stumbling block was that as integrated processors became more powerful, institutions wanted to implement flexible “timesharing” between multiple users.
IBM dismissed this multi-user batch processing was definitely the future! But in 1963, it lost a large MIT contract to General Electric. Realising its huge mistake, IBM developed the general purpose S/360 architecture, which could be implemented on a wide range of compatible systems. In 1965, IBM released the S/360-76, the world’s first mainframe to support virtualisation. And the rest is very much history.
The reasons of 55 years ago remain the same today. Virtualisation is an ideal way of running multiple operating systems on the same hardware, sharing resources and maintaining security through separation. Building walls is good, sometimes. It’s just you don’t need a room sized bit of tech any more; even the most entry level of processors can happily churn out a bit of multi machine virtual loving. I’ve can imagine that almost every Linux user is packing a computer that’ll make a lean, mean virtualisation machine. Toss in the right software, and you’re ready to fire up everything from any number of different distros to a mercifully sandboxed Windows 10 machine and beyond. So, rev up those cores: we’re going virtual machine racing!
You’ve probably already heard of VirtualBox. It’s the best known virtualization software out there, alongside VMware and perhaps Xen, KVM and Hyper-V.
The truth is, VirtualBox is just one of many virtualisation methods, but being open source, easy to use, and over 11 years old, it’s been propelled to the fore over paid for proprietary options such as VMware or Microsoft’s Hyper-V.
Once you’ve got your bare metal OS install just right, the last thing you want to do is mess things up installing dirty software on it.
VirtualBox enables you to try out software, run random services, and even share your system with others without risk of anything ruining your carefully honed setup.
VirtualBox is regularly updated, and you can grab packages for the latest release at www.virtualbox.org, or find instructions for adding the VirtualBox repository to your distro’s package manager and installing it. Do that now!
On mine machine that’s Fedora, this means opening up a terminal window, and running:
And adding YUM repositories.
sudo wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
To update added repositories file execute follow command:
sudo dnf update -y
Followed by installing VirtualBox from the dependency packages.
sudo dnf install VirtualBox-5.2 -y
You could also follow the instructions on the site to line up Oracle’s public keys if you’d like to do a signed installation for example Debian related distro’s . Once the main bulk is installed, be sure to also grab the Extension pack from the VirtualBox site.
What’s in the box?
VirtualBox helps you to build a virtual wall, keeping all invaders safely trapped, running inside a seemingly happy, seemingly real system of their own. Once you’ve installed and fired up VirtualBox, let’s get some lingo down. Your PC hardware, running VirtualBox, is called the host; VirtualBox itself is technically the hypervisor; and any virtualised systems within it, your virtual machines or VMs, are called guests. If you haven’t done so already, start VirtualBox. The main Machine Tools interface displays all your created virtual machines. Click the top right Global Tools button to list all the created virtual media drives, which are the virtual drives you create to store your virtual machines’ OSes and data. Technically, these are reusable and portable, plus you have snapshot and history capabilities, hence the separate manager.
Before we create anything, though, consider where your VMs will be stored. Both the small VM configuration (.vbox) files, and the potentially large virtual media drives (.vdi) and their snapshots. A basic Windows 10 image alone could top 20GB, and if you end up playing with a few VMs, each could easily be 4GB. Snapshots of these systems demand the same level of storage, or more. It adds up fast, so if you’re running a smaller SSD boot drive, you’ll likely want to tell
VirtualBox to store these on a larger data drive. By default, your machines are stored in a folder within your usual /home folder, but you can specify a new location by selecting File>Preferences>General> Default Machine Folder, then clicking Other in the drop-down menu. While you’re here, you might want to visit the Update tab and set VirtualBox to check for new versions once a month rather than daily.
Building a VM…
Click the New button on the top left of the main window,
or use the Machine>New menu. This launches a dialog
that steps you through the creation of a new VM. We’ll
go through this, pointing out some of the finer points to
keep an eye on. Off the bat, you need a unique name for
your VM; you can’t have two VMs with the same title. It’s
also semi intelligent. Type in the name of a known OS,
and it’ll set the type automatically. This, in turn, selects
some default settings, such as memory capacity, based
on what VirtualBox knows is needed.
The choice of 32-bit or 64-bit is important. A 64-bit
host can run both 32- and 64-bit guests; 32-bit hosts
(which aren’t the best idea anyway) are limited to
32-bit guests. You also need to ensure the install media
(we’ll come to this shortly; usually this is a DVD ISO
image) needs to match so, a 64-bit ISO image for a
64-bit guest – otherwise the installer is likely to error at
some point. Click Next. VirtualBox now wants to know how much memory to assign to the VM.
You can’t allocate more than the host machine has, and you’ll need to leave a little for the host OS to keep running. You can generally push it a little further than VirtualBox’s recommendation, however. Next is the virtual hard drive. You can reuse an existing image with the bottom option, but we’re assuming this is your first run, so select ‘Create a virtual disc now’, then click Create. Click the Expert Mode button, and you can edit all the options for your virtual drive at once. The default settings should be adequate. The file type can be changed if you might need to move the drive to another hypervisor. Fixed size drive images offer minor speed increases, but you’ll incur obvious storage implications.
With a dynamically allocated drive, you can happily increase the upper file size without penalty, because it starts off sub-20MB in real size terms and expands with your OS. Finally, you can click the yellow folder icon to check the storage location. At this point, the VM is created, and you can start it, but since we haven’t allocated any boot media yet it won’t get very far. Plus, we have a few more things to do first. Click Settings to discover the full capabilities of your new VM – we’ll go through the highlights in turn. Under General>Advanced, switch both Shared Clipboard and Drag’n’Drop to Bidirectional. Once a guest operating system is up and running, you’ll be able to install a pack of virtual drivers called Guest Additions, part of which offers up the ability to drop files in and out of the guest, plus share a unified clipboard. The System section controls vital motherboard-level and memory settings. Chipset should be set to ICH9 when hosting recent versions of Windows or reasonably modern Linux distros, because it supports PCI Express and modern interrupts.
As a matter of interest, it also supports up to 30 network adapters. Ensure I/O APIC is selected for virtual multi-core support. The Processor tab enables you to set the number of virtual cores and utilization cap. PAE is a processor feature for 32-bit processors that extends memory support beyond the 4GB limit. Some operating systems (Windows 10, for example) expect this to be enabled. Display settings have advanced nicely in VirtualBox. Memory is allocated from the host’s system memory; typically, 16MB is a reasonable amount, but you’ll only need the minimum if you’re running a text mode VM. Multiple virtual displays are supported, while 2D and 3D acceleration are possible via Guest Additions, which we’ll cover shortly. Remote Display is a handy feature enabling Remote Desktop access – we cover this in depth toward the end of the feature. Storage is important in VirtualBox. We won’t go into snapshot management here, just the device settings. VirtualBox should use a SATA controller for your virtual drive by default; there is IDE support for older OSes, plus SCSI, too. Booting for USB and NVMe devices requires EFI support (under System) to be enabled. It’s not recommended that you enable the Use Host I/O Cache option on a VM’s drive controllers, since VirtualBox has its own file system cache: a host system can end up allocating a lot of resources to caching a VM’s read/write activities. It’s also possible to limit individual drive bandwidth, but only via the command
line: see section 5.8 of the VirtualBox manual (www.
virtualbox.org/manual) for more on this.
Several other tweaks…
Attaching your boot media can be done here. These days, if you fire up a VM without any boot media, VirtualBox asks you whether you want to select an image. Typically, this is an ISO file image: you select the optical drive icon, click the top-right optical disc image, and locate your ISO file. If you were doing this for a legacy OS using floppy drives, you’d do the same, but select the floppy image for the floppy controller. We’ll skip the Audio and Serial Ports settings. Audio is largely there to be disabled if required, and if you need a serial port, you really should know what you’re doing. You can skip past Networking too (and it’ll work perfectly), the capabilities here are powerful, and a great way of testing network-attached appliances without putting them into production (as it were) but way beyond what the average home user needs. At the most, if you want to run a network service, select Bridged Adapter in the ‘Attached to’ pull-down. This ensures that your VM gets its own IP address from your local router.
VirtualBox has full USB support, but it needs to be configured for it to identify host inserted or even remote-inserted (when using Remote Desktop Protocol) USB devices. You have two options under the USB section. Either use the green plus icon to add a currently connected physical device to the filter list, or use the blue dot icon to create a general filter rule, including support for remote accessed devices. Finally, our favourite oft-overlooked VirtualBox feature is Shared Folders. When we’ve had issues getting drag and drop to work (sadly it can be finicky) the easiest way to get files on and off a VM is to use this feature. You simply specify a folder on your host system, and this becomes exposed on the guest as a folder, too.
Being naughty in VM…
At this point, you should be primed and ready to launch a perfect virtual machine (VM) guest. You just need an OS install ISO file or do you? It turns out you don’t even have to do any of the work of installing operating systems these days. Pre-built VM images are available, just waiting for you to download them. In the past, we would have had to put in disclaimers about owning Windows licenses, but you don’t have to worry for testing !
Just head to https://developer.microsoft.com and download a developer image of Windows. Fancy something not Windows? I don’t blame you: Linux, in its many, many forms, can be snatched from www.osboxes.org/virtualbox-images. Of course, you can still install from scratch, but you don’t really need to do that either, as www.turnkeylinux.org offers VM and ISO images of every important online service ready to run, from WordPress to OpenVPN. Depending on the format of the downloaded file, you’ll need to do different things. An OVA file is a portable VM image; you import the appliance into VirtualBox via the File>Import appliance menu. A VDI file is a hard drive image: create your VM guest settings, and point the hard drive controller at this. Finally, ISO files are mounted as optical discs, and boot the VM ready to install and run.
As the VM guest first powers up, there’s indeed a virtual BIOS of sorts, so hit F12 to enter this. It doesn’t reach too far: really, it only offers boot device options. Depending on the OS and mode, if the VM captures the pointing device, you press right-Ctrl to swap back out. For Windows, MacOS, and Linux operating system guests, VirtualBox offers to install Guest Additions. Once up and running, you might need to select the Devices>Insert Guest Additions CD menu, and run this from within the VM guest. This installs extensions to the guest OS to enable extended features, such as shared clipboards, seamless mouse support, and on-the-fly window resizing. VirtualBox includes advanced snapshot controls over its drive images. Open the Machine Tools menu and choose Snapshots. This enables you to manage your VM images. Clone should be clear enough: it creates a duplicate image of an existing VM. Snapshots, however, create a delta image of an existing state, so you’re able to revert back to the original snapshot at any point. Opening File>Virtual Media Manager enables you to see these in more detail, alongside being able to physically move them around your system, if you need to. A useful aspect of VirtualBox is its Remote Display Server. It enables multiple users to remotely log in via a Remote Desktop session, and control the VM alongside its headless or detachable VM modes.
This is a server that runs independently of the guest; you need to know the IP address of the PC VirtualBox is running on. To find this, open a terminal window, run ifconfig , and note down the address next to inet <address> on the network adapter you use to connect to your local network.
To set up remote display, in the VirtualBox Display settings for the VM, click the Remote Display tab and select Enable Server. It’s recommended that you change the default port, the port is how TCP-based programs connect to specific network services. Oracle recommends between 5,000 and 5,050, so let’s say 5,000. Run a remote desktop client on another PC (FreeRDP from freerdp.com, or search for RDP if connecting from a Windows machine). Connect to <ipv4 address>:5000 and you should see your virtual desktop; if you’re on the same PC and want to test the connection, use the local loopback address 127.0.0.1:5000. Headless mode can be launched from the GUI by clicking the down arrow next to Start. It launches the VM without a window, just for remote access.
That’s everything you need to know about the basics of VirtualBox, so have some fun!
P.S. If have any questions, please don’t hesitate and contact me via firstname.lastname@example.org or hit me up at Twitter: @0xUID