Enter your email address below and subscribe to our newsletter

How to Install Ubuntu on VirtualBox

Learn how to install Ubuntu on VirtualBox including SSH from host. Will also explain how to create and use snapshots on VirtualBox.

Share your love

Installing Ubuntu in VirtualBox is one of the easiest ways to get started with Ubuntu as you can experiment with the Ubuntu installation, break it multiple times and repeat the cycle till you want.

So in this tutorial, I will walk you through how you can install Ubuntu on VirtualBox. I am using Windows 10 but the steps should remain the same on Windows 11 as well.

In this tutorial, you will learn:

  • Installing VirtualBox on Ubuntu
  • Setting up Ubuntu instance on VirtualBox
  • Enabling bridged network between host and VM
  • Step-by-step installation of Ubuntu on VirtualBox
  • Create and use snapshots in VirtualBox

Let’s start with the first one.

Installing VirtualBox on Windows

This is the first step of this tutorial where you need to visit the official download page of VirtualBox and download the executable file of VirtualBox for Windows:

Download VirtualBox in Ubuntu

Once you are done with downloading VirtualBox, install it on your system (it is no rocket science so I’m skipping the installation part here).

Meanwhile, visit the official download page for Ubuntu and download the latest version of Ubuntu which we are going to use to create a virtual instance of Ubuntu:

Download Ubuntu for VirtualBox

If the download speed is too slow, you can also try the torrent way to download the Ubuntu ISO via alternative methods from Ubuntu.

Setting up Ubuntu VM in VirtualBox

Once you are done installing VirtualBox and Ubuntu ISO, it is time to create a virtual instance of Ubuntu in VirtualBox.

To do so, open VirtualBox from the start menu and press the New button:

Create new Vm in VirtualBox

Next, you will be asked to add some details. First, you need to name the VM. I went with Ubuntu to keep things simple. Next, add the ISO image from the files and lastly, check the “Skip Unattended Installation” to have total control over the installation.

Add Ubuntu ISO in VirtualBox

In the next step, you will be asked to specify system resources. The safe limit is shown as a green colour so I went with 8GB of RAM and 6 cores of CPU power for a smooth experience but you can tweak it as per your computer specs.

Allocate resources for Ubuntu Vm

Now, you will be asked to specify the disk size. I would recommend at least 30GB for a smooth experience and make sure the “Pre-allocate Full Size” is not checked.

This way your computer will not allocate the entire 30GB of storage at once and will increase the size (to 30GB) as the VM grows in size.

Add storage space for Ubuntu VM in VirtualBox

Lastly, it will show you the summary of the choices you made with the VM. Once you read them, you can hit the Finish button to quit the window.

Summary of Ubuntu VM

Before you begin, few tips to consider…

Before you start the Ubuntu installation, I would like to share some configuration tips which were truly useful when I used to use VirtualBox. First, press the Settings button to access the settings page for the Ubuntu VM:

Go to settings of Ubuntu VM

Under the Advanced tab, you will find two options: Shared Clipboard and Drag ‘n’ Drop. Choose the Bidirectional option for both of them to enable a shared clipboard between host and client and facilitate drag-and-drop:

Enable shared clipboard and drag and drop between Ubuntu virtual machine and Windows host

The most important setting is to enable the Bridged Adapter which will allow you to ssh into the VM. This way you no longer have to use the VM for Command line tasks and you can control the VM from a Windows terminal.

Enable brigged network between Ubuntu VM and Windows host

Once done, press the OK button. Now you can start installing Ubuntu by referring to the next section.

Installing Ubuntu on VirtualBox

To initiate the installation, go to the home screen of the VirtualBox, select the Ubuntu VM instance which you’ve recently configured and press the Start button:

Press the start button to install Ubuntu on VirtualBox

It will load the GRUB bootloader giving you three different options. Select the first option titled “Try or Install Ubuntu”:

Select Try or Install Ubuntu

Once you boot from the ISO file, you will meet with a minimal Ubuntu installer and the first thing you have to do is choose the installer language.

By default, it will use English and I believe for most users, it will get the job done. If not, you can choose what suits you best:

Select language for Ubuntu installer in VirtualBox

Next, you’d need to select the keyboard layout which will not only be used for the installer but also for the installation itself.

So make sure you choose the correct keyboard layout and if you have any doubts, you can try the selected layout below the given options:

Select keyboard layout for installer

Now, you will be asked to choose between two options: Install Ubuntu or Try Ubuntu.

The second option would make sense when you are performing the Ubuntu installation on bare metal to check the hardware compatibility but we are proceeding with VM here, so choose the first option “Install Ubuntu”:

Choose the Install Ubuntu option

In the next step, you have two options and both are important.

The default section will give you the least amount of additional apps and will provide you necessary software discluding any office software or games. I personally find this option more useful as it keeps the installation lite.

The Extended selection will include office software, games and extra utilities.

Choose the installation type

Now, you will be asked if you want to install any proprietary software with two options. So if you are going to perform GPU passthrough in future, then you can check the first option.

I would recommend checking the second option to most readers as you might play some music or videos in your VM and at that time, you don’t want any error messages:

Install media codecs for Ubuntu

As we are performing the installation in VM, I’m going with the default option where the system will partition disks by itself:

Select erase disk and install Ubuntu option

Now, you need to create a user for the Ubuntu system where you need to enter Full name, username, hostname and password for the system:

Create a user account for Ubuntu

By default, the installer should pick the timezone and if not, you can choose the timezone by yourself for the correct system time:

Select timezone for Ubuntu VM

Finally, it will show you the summary of the choices you made for installation. If something looks out of place, you can go back and make changes.

If everything looks correct, press the Install button:

Summary of Ubuntu installer

SSH into Ubuntu VirtualBox

To SSH into the recently configured Ubuntu instance on VirtualBox, you must enable the bridged connection between the host and VM.

I’ve already shared how you can enable the bridged connection between VM and host in the previous section titled “Before you begin, few tips to consider…”

So this is the continuation of that part. First, start the Ubuntu instance from VirtualBox and open your terminal to install the OpenSSH server.

The OpenSSH server will allow you to log in to your VM via Windows terminal in the most secure way possible.

Once you open your terminal, execute the following command in the Ubuntu terminal to install the OpenSSH server:

sudo apt install openssh-server
Install OpenSSH server in Ubuntu VM to ssh from Windows

The next step is to find the IP address of Ubuntu. To do so, you can execute the following command:

ip addr show
Find the IP of Ubuntu VM to ssh from Windows to Ubuntu VM in virtualbox

In my case, the Ubuntu VM’s IP is 192.168.1.9.

Once you know the IP of your VM, open the Windows terminal and execute the ssh command in the following manner:

ssh <username>@<IP-address>

As I want to log into my Ubuntu instance, I will be using “kabir” as a username and 192.168.1.9 as IP, so my command would look like this:

ssh [email protected]
SSH into Ubuntu VirtualBox VM from Windows

Use Snapshots in VirtualBox

In this section, I will quickly show you how you can create a snapshot of the current instance and revert to it when you break your system accidentally.

To create a snapshot of the current state, click on the options for a VM and choose the Snapshots option as shown here:

Go to the snapshots section in VirtualBox

Now, click on the Take button and it will open a prompt where you can name this snapshot. For the sake of this tutorial, I have named it “Before 1” (I mean why not?):

Create a snapshot of Ubuntu Vm in VirtualBox

Now, to demonstrate how you can recover the broken system, I’m going to break my system intentionally using the following command:

sudo rm -rf /* 

Here’s what my system looks like after executing the above command:

The broken system to demonstrate how to recover it using snapshots in VirtualBox
The broken system

To recover this using the snapshot, first poweroff this VM and open the snapshots for the Ubuntu VM. There you will find an option to restore the VM.

Here, if you have multiple snapshots, then select a snapshot that you want to use as a restore point and if not, it will select the only available option by default.

Then, press the Restore button, uncheck the option “Create a snapshot of the current machine state” because we don’t need a snapshot of a broken system.

Finally, press the Restore button:

Restore Ubuntu VM using snapshots in VirtualBox

That’s it, from here on you can use the restored system 🙂

Wrapping Up…

In this tutorial, I went through everything a new user might want to know when installing Ubuntu on VirtualBox including how he can set up a bridged connection to have an SSH connection between Windows and Ubuntu VM.

I’ve also explained how you can create a snapshot and restore it. It is important for new users as they might break a VM multiple times and setting up everything from scratch won’t make any sense.

I hope you will find this guide helpful.

Share your love
Kabir
Kabir

A tech journalist whose life revolves around networks.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!