Introduction into VirtualBox
Authors: Mikhail Zolotukhin and Timo Hämäläinen
1. Introduction
VirtualBox is a cross-platform virtualization application. It extends the capabilities of your existing computer so that it can run multiple operating systems (inside multiple virtual machines) at the same time. You can install and run as many virtual machines as you like - the only practical limits are disk space and memory.
You can download the lastest version of VirtualBox for your operating systems from https://www.virtualbox.org/wiki/Downloads. Online user manual for Oracle VM can be found on https://www.virtualbox.org/manual/UserManual.html.
2. Creating a new virtual machine
After installing VirtualBox, we can create a new virtual machine:
- Click on the New button at the top of the VirtualBox Manager window (in new version of VirtualBox it is in Machine −> New). A wizard will pop up to guide you through setting up a new virtual machine (VM).
- On the first page, select name and operating system of new VM. The VM name will be shown later in the VM list of the VirtualBox Manager window, and it will be used for the VM's files on disk. For Operating System Type, select the operating system that you are planning to install later.
- On the next page, select the memory (RAM) that VirtualBox should allocate every time the virtual machine is started. As with the other settings, you can change this setting later, after you create the VM.
Next, you must specify a virtual hard disk for your VM. Create a new, empty virtual hard disk by pressing "New" button. This brings up another window, which helps you create a new disk image file in the new virtual machine's folder, select "VDI" as VirtualBox Disk type. VirtualBox supports two types of image files. A dynamically allocated file will only grow in size when the guest actually stores data on its virtual hard disk. A fixed-size file will immediately occupy the file specified, even if only a fraction of the virtual hard disk space is actually in use. A fixed-size file incurs less overhead and is therefore slightly faster than a dynamically allocated file. To prevent your physical hard disk from running full, VirtualBox limits the size of the image file. Still, it needs to be large enough to hold the contents of your operating system and the applications you want to install - for a modern Windows or Linux guest, you will probably need several gigabytes for any serious use.
In normal circumstances, a dynamically allocated image file with size limit of 25-30 Gb should be enough to create a virtual appliance used in the tutorials of this course.
- After having selected or created your image file, again press Next to go to the next page.
- After clicking on "Finish", your new virtual machine will be created. You will then see it in the list on the left side of the Manager window, with the name you entered initially.
- In order to use the newly created VM, you have to install an operating system. In this course, we will use Ubuntu most of the time. You can download Ubuntu 20.04 from Ubuntu web page.
- Once the image has been downloaded, insert it into CD/DVD drive of your new VM as follows: Settings -> Storage: select CD/DVD drive (it is by default called "Empty" and can be found in "Storage Tree" under "Controller: IDE"), click on "Disk with tiny arrow"-icon in the right top corner, select "Choose Optical Virtual Disk File..." in drop-down menu and browse to the ISO-image you downloaded. Click OK.
Start VM and proceed with installing the operating system.
If you have never run VirtualBox or other virtualization software on your laptop, there is high probability, that virtualization is disabled in your computer's BIOS. You will notice that if you start a VM and see an error messege of kind "VT-X is disabled...". You should enable it in BIOS: restart computer, when it is starting up, enter BIOS by pressing the required key. The key can be F2, F10, etc depending on the manufacturer. Find "VT-X" or "Virtualization" or something similar to this in "Device Configuration" (menu title also can be different in your case) and enable it. The easiest way to find out how to do it is to google "How to enable virtualization on" and add the model of your laptop. Once virtualization has been enabled, save changes and exit BIOS. After reboot, you should be able to start your VM.
In Linux, one more error message that you might see when staring your VM for the first time looks as follows: "Kernel driver not installed (rc=-1908). The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv". In this case, you have to disable "Secure boot" in your laptop's BIOS. If you do not want to disable "Secure Boot", try this method.
3. Assignment
Create one virtual machine in VirtuaBox, name it "testvm", allocate 2 GB of RAM and 10 GB of hard drive for your VM. Download an ISO image of Ubuntu Desktop 20.04 and install it on the VM. Make sure that you are able to use operating system after installation and have access to the Internet.
4. Conclusion
In this tutorial, we got familiar with VirtualBox, created our first VM and installed Linux on it.
These are the current permissions for this document; please modify if needed. You can always modify these permissions from the manage page.