How To Create a Ubuntu Virtual Machine (VM) with VirtualBox in 2022
Oracle VirtualBox is a virtualization program that runs on multiple Operating Systems.
VirtualBox can be installed on your current Intel or AMD-based machines, whether they run Windows, Mac, Linux, or Solaris.
In a window of the host operating system, VirtualBox enables you to generate and operate on a “guest” operating system (virtual machine), Without having to spend on costly hardware for a new PC.
Ubuntu (pronounced oo-BOON-too) is an open source Linux distribution based on Debian that is mostly comprised of free and open-source software.
Ubuntu is officially available in three editions: Desktop, Server, and Core for IoT devices and robots.
All editions can operate on their own computer or in a virtual machine.
For this tutorial, We will Download the VirtualBox installer from the following link and install VirtualBox hypervisor:
First, to install the Ubuntu OS into the newly created VM, we need to first download a ubuntu iso image from (either as a direct download or torrent):
Setting up a new VM
Running the downloaded setup file is pretty much self explanatory, just click next on everything ;)
Open VirtualBox > Tools > New
In the dialog box that pops up, provide a suitable name for the new VM
Next, allocate an appropriate amount of RAM to the VM
Add a virtual hard disk to the new VM. By either creating a new hard drive file or selecting one from the list or from another location.
Choose the file type of the virtual hard disk for the new virtual hard drive (we will select VDI (VirtualBox Disk Image) considering native compatibility.)
Select if the VM’s virtual hard disk should expand/ shrink as it is used or if VirtualBox has to allocate the given file size,
we will use dynamically allocated option as it will shrink and expand as data are filled in to the virtual hard disk allowing us to use our disk space as needed,
but it should be noted that a fixed size hard disk will take more time to create but can be comparatively faster, but if the host machine has a SSD, it might not be of significance.
Next, we need to select the size of the virtual hard disk, for this VM we can select up to 15–20 GB as the OS itself will take around 8 GB and for smooth operation in case we want to use the VM for other purposes in future.
Now, clicking on “Create” will create our fresh VM.
Select/ Create a NAT Network
If you have not created a NAT network prior, go to:
File > Preferences > Network and click on the Add button to add a new NAT Network in case of a fresh installation and click OK.
Select/ Load installation media to the VM
Under storage tab in settings dialog box, select the IDE controller for optical devices and select Choose/ Create a Virtual Optical Disk…
Click on Add to browse and load the iso image file from the downloaded location.
Select the downloaded image and click on open.
Select the Ubuntu ISO image and click “Choose”
Which will load the ISO image to the IDE optical controller.
Configuring the virtual network.
Next go to settings of the created VM to provide the downloaded iso image file and to configure the network.
Go to the Network tab. By default, NAT is the attached interface, we will change this to NAT network we previously created, Not bridged, due to the risk of exposing the host network to the vulnerable VM, and this will allocate separate IP addresses for our VMs.
Click OK and Start the newly created Ubuntu VM to begin installation.
Installing Ubuntu
We will be going with the default installation options, from the Welcome screen select Install Ubuntu.
Continue with the default keyboard layouts.
Since we will be using this for hosting purposes, we can select Minimal Installation to reduce installation time while saving hard disk space. And its optional to install and download the latest updates while installing.
We will select Erase disk and install ubuntu as this is a fresh installation, which will format the virtual hard disk and install the OS
Click continue for the prompt to write the changes to disk.
Next screen needs us to provide our location for clock adjustment, click Continue
On the next screen provide a username and a password and if required computer name. We select the login automatically option to avoid typing the password every time we login, since this is a VM. There are some advantages to this like saving time plus we can run the VM headless with a detached GUI in the background, which will save us more RAM on the host machine.
The installation will begin, and it will take time.
After installation in completed, we get a prompt to restart,
we will detach/ eject the installation media iso file and reboot. (Make sure the ubuntu iso is not selected from Devices > Optical Devices > ubuntu.iso)
Installing VirtualBox Guest Additions (Optional)
Once Ubuntu boots up, insert the VBox Guest Additions iso image from: Devices > Optical Devices > VBoxGuestAdditions.iso And run the installer by clicking “Run”
Prompted for password, provide the password provided in installation.
A terminal pop up indicates the installation of VirtualBox Guest Additions, once done, reboot the VM as kernel modules are not replaced until the system is restarted, it is recommended to take a snapshot of the VM after this stage.
With that you have a fully functional Ubuntu VM at your disposal, installing VirtualBox Guest Additions optimize the operating system for better performance and usability. One of the usability features required in this guide is automated logons, which is why you need to install the Guest Additions in the virtual machine.
But also keep in mind that Even without guest extensions there could be a flaw in VirtualBox, allowing malware to attack the host system. Installing guest extensions will put you at higher risk, because the extensions allow closer access to the host system to enhance performance and thus allows more attack vectors.
If you liked the content share this around :)