Virtual Machines, or VMs, make it possible for us to install, test and use operating systems by loading them within another operating system using without needing more than one computer. No dual booting necessary. VMs give us the power to load Windows software in Linux or to load Linux software in Windows or even to load one Linux OS within another Linux OS.
A good explanation of how virtual machines work is written at Wikipedia.
There are two words you need to know when talking about virtual machines: Host and Guest.
Think of the relationship between host and guest as being like the relationship between a computer OS and a software application installed within the OS.
- The host is the computer environment that controls a virtual machine’s operation.
- The guest is the simulated computer environment that works within the confines set by the host.
- The host is the house that provides a home for the guest to work within.
There are more than one virtual machine software available. Called virtualizers and emulators, each type has its own pros and cons. Three popular VM software are:
- FAUMachine which emulates machine hardware environments and lets us deliberately insert hardware faults and software faults into guest systems.
- QEMU which emulates a variety of computer architecture types so is excellent for trying software aimed at operating systems running on hardware other than the hardware we physically have available to us.
- VirtualBox which uses a host system’s hardware to allow a guest OS to function by allowing it to directly access the host operating system’s hardware.
VirtualBox is my favourite VM software for general use purposes. It is fast and simple to use. This guide will show you how to use VirtualBox and how to install a guest OS within a host environment.
How to use VirtualBox
From this point on I will show you how to create virtual machines using VirtualBox. This guide includes step-by-step instructions and videos that will teach you how to
- Create a virtual machine with VirtualBox
- Change the virtual machine’s Settings
- Run the virtual machine and install an OS
- Install Guest Additions
- Increase virtual drive size
These instructions apply to both Windows and Linux hosts.
VirtualBox has a simple intuitive user interface. This is one of the reasons I like it. VirtualBox is incredibly easy to use.
- Open VirtualBox
- Click New at the top left hand side of the dashboard window
- Follow the prompts in the Create Virtual Machine dialogue screen
- Set the base memory size (the RAM) for the VM to be at least 2GB. Many VMs will work with less RAM but more RAM will give a better VM experience.
- Set the hard disk size to be at least 8GB. Use a dynamically allocated drive so that the actual drive size grows as needed. When a dynamic drive is used the drive space is not reserved so can still be used by the host OS. A Dynamic HDD size is effectively a maximum growth size. The drive size can be increased later.
- The location of the virtual HDD file can be set to be on any drive accessible to the host machine.
- Click Finish to confirm your settings.
The default settings for VirtualBox VMs are a little bit meek so we need to configure the VM to give it more power.
Set up your virtual machine
- Select a virtual machine from the list in the left-hand panel of the VirtualBox dashboard
- Click Settings at the top of the dashboard window
- In the Settings dialogue screen, make configuration changes for the following settings tabs
- General > Advanced
- Shared Clipboard: Bidirectional
- Drag’n;Drop: Bidirectional
- System > Motherboard
- Increase the machine’s Base Memory if more RAM is required
- Disable the Floppy drive unless you need it
- Set the CD/DVD ROM drive as the first boot device. Change this back to Hard Disk after your OS is installed
- System > Processor
- Set the number of virtualised processors
- Enable PAE/NX if available
- System > Acceleration
- Enable VT-x/AMD-V
- Enable Nested Paging
- Display > Video
- Increase the Video Memory size. This uses the system’s Base RAM
- Enable 3D Acceleration
- Set the HDD to Solid State Drive if the guest HDD file is stored on an SSD drive
- More hard disks can be added through this menu
- CD ROMs can be inserted from this menu
- Enable Audio and confirm that the correct Host Audio Driver and Audio Controller are selected. This should be correct by default.
- Enable the network adapter. The default settings are generally good though if you have connection problems, choose NAT.
- Serial Ports
- Enable the serial port if you have any devices attached to serial ports of your host machine and want to access them through the guest machine
- Enable the USB Controller
- Enable USB 2.0 (EHCI) Controller if the host machine has USB 2 capable ports
- Shared Folders
- To share a folder located on the host machine so it can be accessed by the guest computer you need to click the blue folder icon with the green plus sign on it to bring up the Add Share dialogue box. Next to Folder Path is a dropdown arrow. Click the arrow to choose a folder to share. The shared folder will be automatically accessible to the guest machine on every boot only if you enable Auto-Mount. The shared folder can be written to by the guest machine unless you enable Read-Only (advisable when the guest uses a Windows OS).
- General > Advanced
- Click OK to save the settings.
A newly created virtual machine with a newly created virtual hard disk is born into the virtual world with no operating system. We need to install an OS. We can install an OS from a disc ISO image. An ISO file is a disc image that is ready to be written to CD, DVD or memory stick. We do not need to write an ISO to CD, DVD or USB disc to use the ISO with VirtualBox.
Linux ISOs are free to download. If you need one you can get one from Ubuntu or Kubuntu.
The next step in using VirtualBox is to add an operating system ISO image and run the machine to install the ISO image.
Mounting the Operating System ISO
Assuming you now have an ISO image to install,
- Open your virtual machine’s settings as you did when configuring it in the previous step
- Go to the Storage settings
- Select Controller: IDE
- Click the green plus sign on the circular disc icon (the two displayed icons are different)
- Choose your OS disc ISO
- Save the new VM settings.
Start the virtual machine
With the boot CD inserted into the VM we can now install an operating system for our virtual machine.
- Select the virtual machine from the list of machines in the left-hand-side of the VirtualBox dashboard
- Click Start at the top left of the VirtualBox dashboard
- Click the window that shows the virtual machine loading up. Doing this will cause the virtual machine to take control of the host computer’s mouse and keyboard. You can release the mouse and keyboard back to the host machine’s control by pressing the host keyboard’s right-hand-side control (Ctrl) key
- Follow the screen prompts to install the OS
When the OS is installed you will be prompted to reboot the VM (Virtual Machine). Reboot the machine, switch off the machine if the option is presented. Stop the machine before it restarts. We need to unmount (eject) the operating system ISO image.
Enter the virtual machine’s settings from the VirtualBox dashboard
- Select Storage
- Right-click the operating system CD’s ISO image
- Select Remove Attachment.
Now you can restart the virtual machine and use it as you would any other computer.
Guest Additions is the program created by Sun Micro Systems to enable guest environments to work seamlessly within the host operating system. It removes the need for the guest OS to capture the mouse and keyboard, it allows the guest to work in a non-windowed mode, and it facilitates the easy set-up of file and drive sharing.
Guest Additions is easy to set-up and is automatically downloaded by Virtual Box.
- Launch the guest OS
- When the guest’s desktop is loaded, move the mouse cursor to the Devices menu at the top of the window and select Install Guest Additions. This will mount an iso image called VirtualBox Guest Additions.
- Linux and other *nix guests only:
- Open a file browser in the guest OS
- Browse to the disc labelled VirtualBox Guest Additions
- Run the file autorun.sh as a sudo user. You might need to make the file executable first.
- Windows guests only:
- Windows guest machines should auto run the Guest Additions program. Follow the dialogue prompts.
- Linux and other *nix guests only:
- Guest Additions should now be installed. After restarting the virtual machine the guest and host will be more closely integrated
Access files stored on the host machine
This is explained above here in the section titled ‘Set up your virtual machine’.
VirtualBox discs can be given more capacity. We have to use the command line to resize the disc. Yep, we need to open a terminal window to increase the size of a virtual disc. The process is simple to follow.
From the host operating system:
- Open a terminal or console window like CMD or Konsole
- List the available virtual discs
VBoxManage list hdds
- Note the location and name of the disc you want to resize
- Use the following command to change the disc’s size
VBoxManage modifyhd drive-name.vdi --resize 99999
- Change ‘drive-name.vdi’ to the path and name of your disc
- Change ‘99999’ to reflect the new size in MB of the discs capacity
- Load the guest OS and use a disc management program within the guest OS to tell the OS to use the additional disc capacity.
The command VBoxManage modifyhd cannot be used to decrease the size of a disc drive.
Add your voice
Use the comment form to tell us your thoughts and to ask us questions.