Installing Ubuntu Desktop 22.04 LTS on a virtual machine using VirtualBox

Marc Lameriks 2

For a TypeScript training, I needed an environment with Visual Studio Code and Node.js (a JavaScript runtime).

On my Windows laptop, I wanted to create an environment with Ubuntu as guest Operating System, Visual Studio Code and Node.js available within an Oracle VirtualBox appliance.

In this article, I will share with you the steps I took, to get this working within an Oracle VirtualBox appliance. In this article the focus will be on manually installing Ubuntu Desktop.

In a later article I will describe, as an alternative, installing Ubuntu Desktop with the help of Vagrant, including Visual Studio Code and Node.js.

Visual Studio Code

Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages and runtimes (such as C++, C#, Java, Python, PHP, Go, .NET).
[https://code.visualstudio.com/docs]

Node.js

As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications
[https://nodejs.org/en/]

Manually installing Ubuntu Desktop

For installing Ubuntu Desktop using VirtualBox, I followed the instructions “How to run Ubuntu Desktop on a virtual machine using VirtualBox”:

https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#1-overview

Next, I will describe these installation steps. Because not everything went according to plan. Among others, I also had a look at “How to Install Ubuntu 22.04 LTS Linux on VirtualBox using Windows 10” via https://www.youtube.com/watch?v=zHwFtyxJsog, which was very helpful.

Download an Ubuntu Image

I downloaded Ubuntu 22.04 LTS (ubuntu-22.04-desktop-amd64.iso (3,40 GB)), the latest LTS version of Ubuntu, for desktop PCs and laptops. LTS stands for long-term support — which means five years, until April 2027, of free security and maintenance updates, guaranteed.

Recommended system requirements:

  • 2 GHz dual-core processor or better
  • 4 GB system memory
  • 25 GB of free hard drive space
  • Internet access is helpful
  • Either a DVD drive or a USB port for the installer media

[https://ubuntu.com/download/desktop]

Download and install VirtualBox

I already had VirtualBox on my Windows laptop. I upgraded the version to:
Version 6.1.36 r152435 (Qt5.6.2)

Create a new virtual machine

I created a new virtual machine, with the following details:

On the next screen, I selected the amount of RAM from my Windows laptop that the virtual machine will access, taking into account the recommended system requirements for Ubuntu Desktop.

After that, you can select how much of your hard disk your VM will use.

The type of hard disk depends on whether you use VirtualBox with other VM software. I kept this as a VDI.

Then you can choose whether the hard disk is dynamically allocated (up to the limit we will set on the next screen), filling up as the VM requires it. Otherwise, we can tell it to allocate the full amount of memory right from the start. This will improve performance but may take up unnecessary space. I kept it as dynamically allocated.

Finally, you can set the maximum amount of memory your VM can access.

I selected 25 GB, taking into account the recommended system requirements for Ubuntu Desktop.

After this I clicked the ‘Create’ button to initialize the machine.

Before starting the appliance, via Settings | System | Processor, I changed the number of CPUs to 2.

Install your image

Click the ‘Start’ button to launch the virtual machine. You will be prompted to select the start-up disk. Use the file icon to open the Optical disc selector and click Add to find your .iso file.

Next, choose ‘Install Ubuntu’.

Ubuntu Desktop should now boot and display the installation menu.

Because I was following the instructions “How to run Ubuntu Desktop on a virtual machine using VirtualBox”, the next step was to change the window resolution first.

Changing the window resolution (by using VBoxSVGA)

I did follow these instructions, but in the end got in to trouble, because after the installation and reboot the login screen did not appear.

You’ll notice that by default VirtualBox only displays at 800×600 resolution. But if you right click the ‘Window in monitor’ icon at the bottom of the screen (or via the menu: View) and select ‘Virtual Screen 1’, there are many more options available, but greyed out.

According to the instructions, to resolve this, I needed to change some settings. I closed the window and selected ‘Power off the machine’ (via the menu: File | Close | Power off the machine).

I returned to the Oracle VM VirtualBox Manager window and selected ‘Settings’. Then navigated to the Display tab. Changed the Graphics Controller setting to ‘VBoxSVGA’ and clicked OK (ignoring the warning).

Next, I started my virtual machine.

Once Ubuntu has started, you should now be able to select all of the available resolutions from the ‘Virtual Screen 1’ menu, or simply resize the window to adjust the display.

As I mentioned before, I did follow the instructions, but in the end got in to trouble, because after the installation (these same installation steps are described later on in this article) and a reboot, the login screen did not appear.

So, I opted for another way of doing things.

I selected ‘Power off the machine’ (via the menu: File | Close | Power off the machine).

I returned to the Oracle VM VirtualBox Manager window and selected ‘Settings’. Then navigated to the Display tab. Changed the Graphics Controller back to ‘VMSVGA’.

Then I navigated to the System tab, selected ‘Enable EFI’ and clicked OK.

Remark about Enable EFI:
Enables Extensible Firmware Interface (EFI), which replaces the legacy BIOS and may be useful for certain advanced use cases. See Section 3.14, “Alternative Firmware (EFI)”
[https://www.virtualbox.org/manual/ch03.html#settings-system]

Next, I started my virtual machine.

Continuing the installation of Ubuntu Desktop

In the “Welcome” window, the preferred language ‘English’ is selected.
To install Ubuntu, I clicked on the ‘Install Ubuntu’ button.

In the “Keyboard layout” window, as the preferred keyboard layout, ‘English (US)’ is selected.
Next, I clicked on the ‘Continue’ button.

In the “Updates and other software” window, I kept the defaults: ‘Normal installation’ and ‘Download updates while installing Ubuntu’.

The minimal installation is useful for those with smaller hard drives or who don’t require as many pre-installed applications.

In Other options, you will be prompted to download updates as well as third-party software that may improve device support and performance (for example, Nvidia graphics drivers) during the installation. It is recommended to check both of these boxes.

If you are not currently connected to the internet, you will be prompted to do so at this point. Ensure you are able to remain connected throughout the installation.
[https://ubuntu.com/tutorials/install-ubuntu-desktop#5-installation-setup]

I also selected the ‘Install third-party software’ option.

Next, I clicked on the ‘Continue’ button.

In the “Installation type” window, I kept the default: ‘Erase Disk and install Ubuntu’.
Next, I clicked on the ‘Install Now’ button.

In the “Write the changes to disks?” pop-up window, I clicked on the ‘Continue’ button.

In the “Where are you?” window, I selected my location and timezone from the map screen and clicked on the ‘Continue’ button. This information will be detected automatically if you are connected to the internet.

In the “Who are you?” window, I filled in the fields and clicked on the ‘Continue’ button.

On this screen, you will be prompted to enter your name and the name of your computer as it will appear on the network. Finally, you will create a username and a strong password.

You can choose to log in automatically or require a password. If you are using your device whilst travelling, it’s recommended to keep automatic login disabled.
[https://ubuntu.com/tutorials/install-ubuntu-desktop#9-create-your-login-details]

After that, the installation process starts.

At the end of the installation process, you have to restart the computer. I clicked on the ‘Restart Now’ button.

When you restart, you will be prompted to remove your installation medium from the device.

However, you don’t have to remove the installation medium and can immediately press ENTER.

Next, enter your password on the login screen (assuming you selected that option when creating your login details).

Next, I had to step through some welcome screens.
I mostly used the ‘Skip’ or ‘Next’ button.

Here, I chose not to send system info.

Then a pop-up appeared concerning updated software:

I clicked on the ‘Install Now’ button.

After a while the updates were installed and in the final pop-up, I clicked on the ‘Restart Now’ button.

Again, I had to enter my password on the login screen.

And again, I had to step through some welcome screens.
I mostly used the ‘Skip’ or ‘Next’ button.

I clicked on the ‘Next’ button, skipping the set up of Livepatch.

Again, I chose not to send system info.

Finally, I clicked on the ‘Done’ button.

A few more things had to be done. But first, I moved the ‘Home’ folder to another position on the desktop.

Display Settings

I right clicked on the dashboard and choose ‘Display Settings’.

I changed the default resolution from “1024 x 768” to something more suitable for my Windows laptop.

Installing Guest Additions

Guest Additions is an extra piece of software that unlocks some more advanced features of VirtualBox. This includes better integration between your virtual machine and the host machine, as well as improved video support that enables the display resolution options when using VMSVGA.

To install Guest Additions, you need to complete your installation of Ubuntu in your virtual machine and boot to the desktop.
[https://ubuntu.com/tutorials/how-to-run-ubuntu-desktop-on-a-virtual-machine-using-virtualbox#5-installing-guest-additions]

From the VirtualBox menu, I selected Devices | Insert Guest Additions CD image.

Then you will notice on the left-hand side, that a VBox_GAs_6.1.36 image appears.

I clicked on the icon to show it’s content.

I right clicked on file autorun.sh and chose ‘Run as a program’. Next, I entered my password.

After that, the VirtualBox Guest Additions installation started.

Checking the results above, you can see the following error occurred:

“This system is currently not set up to build kernel modules”.

In order to fix this, I followed the instructions from “How to Install Ubuntu 22.04 LTS Linux on VirtualBox using Windows 10”. I opened a terminal (via Activities):

In the search field I typed: terminal

I clicked on the ‘Terminal’ icon and then I used the following command:

sudo apt update

With the following output:

Next, I used the following command:

sudo apt install build-essential

Remark about build-essential:
This package contains an informational list of packages which are considered essential for building Debian packages.
[https://packages.debian.org/sid/build-essential]

With the following output:

After I entered Y, the script continued.

Then I repeated the previous steps, starting with a right click on file autorun.sh and choosing ‘Run as a program’, etc.

Checking the results above, you can see, this time it worked. I closed the window by pressing Return.

And I closed the system, via the VirtualBox menu, File | Close | Save the machine state.

Next, I started my virtual machine and entered my password on the login screen.

From the VirtualBox menu, I selected View | Auto-resize Guest Display.

This nicely resized the display.

Next, from the VirtualBox menu, I selected Devices | Shared Clipboard | Bidirectional.

Remark about Shared Clipboard:
You can select here whether the clipboard of the guest OS should be shared with that of your host. If you select Bidirectional, then Oracle VM VirtualBox will always make sure that both clipboards contain the same data. If you select Host to Guest or Guest to Host, then Oracle VM VirtualBox will only ever copy clipboard data in one direction.
[https://www.virtualbox.org/manual/ch03.html#generalsettings]

Next, from the VirtualBox menu, I selected Devices | Drag and Drop | Bidirectional.

Remark about Drag and Drop:
This setting enables support for drag and drop. Select an object, such as a file, from the host or guest and directly copy or open it on the guest or host. Multiple drag and drop modes for a VM enable restricting of access in either direction.
[https://www.virtualbox.org/manual/ch03.html#generalsettings]

Finally, I closed the system, via the VirtualBox menu, File | Close | Save the machine state.

So now, on my Windows laptop, I had an environment with Ubuntu Desktop, available within an Oracle VirtualBox appliance. This environment gave me a basis for installing other software (like Visual Studio Code and Node.js), I needed for the TypeScript training.

In this article, I shared with you the steps I took, to get this working.

In a later article I will describe, as an alternative, installing Ubuntu Desktop with the help of Vagrant, including Visual Studio Code and Node.js.

2 thoughts on “Installing Ubuntu Desktop 22.04 LTS on a virtual machine using VirtualBox

  1. I also used virtual box in the past but now using WSL2 (windows dub system linux) native in windows is much faster to start a vm (almost instant) and theres no need of extra layer translating vm O.S. into host O.S. because in WSL2 vms run directly by host O.S.

    We enable wsl2, then get ubunto via Microsoft app store, and visual studio code automatically detects linux vm so asks/will install extensions server side on the linux vm with simple click, meaning one can debug line by line, set breakpoints, while developing in python for example.

  2. Hi Marc. Nice and extensive blog post! Just for some additional information, I encountered some issues when installing Ubuntu 22.04 in VirtualBox using Vagrant. The first one was that VirtualBox 6.1.32 and 6.1.34 did not work for me with multiple CPUs. This could very likely be related to Hyper-V support changes in VirtualBox (see https://forums.virtualbox.org/viewtopic.php?f=6&t=105741). Downgrading to 6.1.30 solved this issue. Another issue was Wayland which did not play nice with me. I disabled it by doing the following: sed -i ‘s/\#WaylandEnable\=true/WaylandEnable\=false/g’ /etc/gdm3/custom.conf. After that I could install Ubuntu 22.04 using Vagrant without issues.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Next Post

Azure API Management: Integration with Standard Logic Apps

In January 2022 there was a blog published on the Microsoft Tech Community that demonstrates how to integrate Azure API Management with Logic Apps (Standard). As mentioned in that blog, the functionality to import workflows in Logic Apps (Standard) is not yet available in API Management, only Logic Apps running […]
%d bloggers like this: