Hello dear friends. You are interested in installing Linux on VM most likely because your organization wants you to use linux or you are getting into modern DevOps, which usually works much better on linux than on Windows or Mac, but you don’t want to leave your preferred os — may be windows or Mac OS or you want to experiment with a new software without risking the host OS. Whatever the reason may be, Oracle VirtualBox provides an elegant way for running multiple virtual machines with different OSes on your machine. That too, you can seamlessly switch between your virtual machines just like you would switch between different apps running on your machine. Awesome! Isn’t it?
What is VirtualBox?
Oracle VirtualBox is a cross-platform virtualization application. It installs on your existing Intel or AMD-based computers, whether they are running Windows, Mac, Linux or Solaris operating systems. VirtualBox can create and run a “guest” operating system ( virtual machine) in a window of the host operating system. The virtual machine provides a self-contained environment in which you can experiment with new software without risking any damaging changes to the host operating system.
In this story I will show how to install VirtualBox and create a new virtual machine with an example of installing Ubuntu OS as a guest machine. You will also learn how to share files between the host and guest operating systems.
Download and Install VirtualBox
Go to VirtualBox website and download the installer for your current operating system. Since my host machine is running on Windows, I’ll choose “Windows hosts”. When download is finished, run the executable file and continue with the installation with the defaults.
Note: instruction here are based on the latest version of the VirtualBox. If you have already installed an earlier version of VirtualBox, your experience may be different. It is recommended to use the latest version of VirtualBox to avoid issues. The VirtualBox forum is a good place to find a solution if you see any problems.
Create Virtual Machine
Open the VirtualBox application and Click ‘New’ button to open the Create Virtual Machine dialog.
Type a name for the new virtual machine. Since I am planning to install Ubuntu, I’ll enter ‘My Ubuntu VM’. Note that VirtualBox automatically detected the term “Ubuntu” and changed ‘Type’ to Linux and ‘Version’ to ‘Ubuntu (64 bit)’. These two options are exactly what we need. You are free to choose any name of your choice and manually configure the options below as well.
Click Next and select memory size that you want to allocate to the VM. I have 16 GB RAM on my windows machine. I like to allocate 8GB for Ubuntu and leave 8 GB for my Windows host machine. Thus, I pick 8192 MB for my Ubuntu.
Click Next and accept the default ‘Create a virtual hard drive now’ and click ‘Create’ button.
Continue to accept the default ‘VDI’ drive file type and click ‘Next’ button.
Change the storage type from the default ‘Dynamically allocated’ to ‘Fixed size’ to increase performance.
For the virtual hard drive space, the default value is 10GB which is too little. I’ll pick 100GB since I have plenty of space in my hard disk. If you realize the drive space is not large enough, you’ll need to go over these steps again to create another virtual machine.
Click ‘Create’ button and VirtualBox will generate Ubuntu virtual machine.
Wait for the virtual machine to be created. While it is being created make sure you have downloaded the OS image (ISO file) for your guest operating system, in our case the latest long term supported version of Ubuntu.
Install Ubuntu on the Virtual Machine
Let us now install OS on the Virtual Machine that we just created. In our case, we are going to install the latest version of Ubuntu on our virtual machine from https://ubuntu.com/download/desktop. However, you can choose Linux distribution or any other OS of your choice. Just make sure you select appropriate options in the first step — Create Virtual Machine dialog. Also make sure the VT-x/Virtualization Technology has been enabled in your computer’s BIOS/Basic Input Output System.
Once it is created, we are ready to install Ubuntu on this virtual machine. Select your new virtual machine and click ‘Settings’ button. Click on ‘Storage’ category and then ‘Empty’ under Controller:IDE. Click “CD/DVD” icon on right hand side and select the ubuntu ISO file.
Since most modern programs can take an advantage of multiple processors/threads, it is a good idea to specify a large number of processors in virtual machine (default value is 1). You can change this number by clicking on ‘System’ category.
Also you can go to advanced tab under General Settings to enable shared clipboard as shown so that you can copy and paste data between guest and host OSes.
Now click OK to save the settings and go back to Oracle VM VirtualBox Manager. Click on the new Ubuntu virtual machine and hit ‘Start’ button. Now you shall see a ‘Welcome’ screen. Click ‘Install Ubuntu’ button. Note that the installation process may differ a little bit from version to version. The screenshots here are based on Ubuntu 14.04.1.
Note that there are 3 start modes to start a VM: Normal Start, Headless Start and Detachable Start.
VirtualBox may pop up a message about ‘Auto capture keyboard’ option. Read the message there and check ‘Do not show this message again’ option before clicking OK.
Click ‘Continue’ button.
Make sure ‘Erase disk and install Ubuntu’ option is selected and click ‘Install Now’ button.
Ubuntu will ask you a few questions. If the default is good, click ‘Continue’ button.
In ‘Who are you?’ dialog, enter your preferred name, username and password. Note that this user will have root/sudo privilege. Click ‘Continue’ button.
The installation will continue until it is finished.
After installation is complete, click ‘Restart Now’ button. When you see a screen with a black background saying ‘Please remove installation media and close the tray (if any) then press ENTER:’, just follow it.
Enter the password you have chosen and press ‘Enter’.
The Ubuntu Desktop OS is ready. You may find the desktop screen is too small. Don’t worry. You can solve this easily with “VirtualBox Guest Additions”.