How to run an Ubuntu Desktop virtual machine using VirtualBox 7

Key Value
Summary Learn how to run Ubuntu Desktop on any operating system using VirtualBox to set up a virtual machine with this quick start guide.
Categories desktop
Difficulty 1
Author Oliver Smith oliver.smith@canonical.com

Overview

Duration: 1:00

In this tutorial, we’ll walk you through one of the easiest ways to try out Ubuntu Desktop on a virtual machine. VirtualBox is a general purpose virtualiser that is available across Linux, Mac OS and Windows. It’s a great way to experience Ubuntu regardless of your current operating system.

VirtualBox 7 and above includes a new feature called Unattended Guest OS Install which significantly streamlines the setup experience for common operating systems like Ubuntu, making it easier than ever to get started.

Note: This tutorial will also work for other distributions, so try it out with some of the Ubuntu flavours as well!

What you’ll learn

  • How to install and configure VirtualBox
  • How to import an Ubuntu image
  • How to run a virtual instance of Ubuntu Desktop
  • Further configuration options

What you’ll need

  • A PC with internet access!

Download an Ubuntu Image

Duration: 3:00

You can download an Ubuntu image here. Make sure to save it to a memorable location on your PC! For this tutorial, we will use the latest Ubuntu 22.10 release.

Download and install VirtualBox

Duration: 5:00

You can download VirtualBox from the downloads page here. This page includes instructions on how to install VirtualBox for your specific OS so we won’t repeat those here.

Once you have completed the installation, go ahead and run VirtualBox.

Create a new virtual machine

Duration: 5:00

Click New to create a new virtual machine. Fill in the appropriate details:

  • Name: If you include the word Ubuntu in your name the Type and Version will auto-update.
  • Machine Folder: This is where your virtual machines will be stored so you can resume working on them whenever you like.
  • ISO Image: Here you need to add a link to the ISO you downloaded from the Ubuntu website.

We want to install Ubuntu unattendedly so we can leave the checkbox to skip unchecked.

Create a user profile

To enable the automatic install we need to prepopulate our username and password here in addition to our machine name so that it can be configured automatically during first boot.

The default credentials are:

  • Username: vboxuser
  • Password: changeme

It is important to change these values since the defaults will create a user without sudo access.

Ensure your Hostname has no spaces to proceed!

It is also recommended to check the Guest Additions box to install the default Guest Additions ISO that is downloaded as part of VirtualBox. Guest additions enables a number of quality of life features such as changing resolution and dynamic screen resizing so it is highly recommended!

Note: If you choose not to use unattended install then this step will be skipped and you will go straight to the following screen. Once your machine has been created you will be able to create a username and password by proceeding through the standard Ubuntu Desktop installation flow on first boot.

Define the Virtual Machine’s resources

In the next section we can specifiy how much of our host machine’s memory and processors the virtual machine can use. For good performance it’s recommended to provide your VM with around 8GB of RAM (althought 4GB will still be usable) and 4 CPUs. Try to remain in the green areas of each slider to prevent issues with your machine running both the VM and the host OS.

Then we need to specify the size of the hard disc for the virtual machine. For Ubuntu we recommend around 25 GB as a minimum. By default the hard disk will scale dynamically as more memory is required up to the defined limit. If you want to pre-allocate the full amount, check the ‘Pre-allocate Full Size’ check box. This will improve performance but may take up unnecessary space.

Click Next to continue and view a summary of your machine setting.

After this click Finish to initialize the machine!

Install your image

Duration: 10:00

Click Start to launch the virtual machine.

You will see a message saying ‘Powering VM up …’ and your desktop window will appear.

On first boot the unattended installation will kick in so do not interact with the prompt to ‘Try and Install Ubuntu’ and let it progress automatically to the splash screen and into the installer.

Note: If you chose not to use unattended install then you will need to progress through the Ubuntu install manually. Check out our Ubuntu Desktop installation tutorial for more details.

You will notice at this stage that the resolution of the window is fixed at 800x600. This is because the Guest Additions features are not installed until after the Ubuntu installation has completed.

Once the installation completes, the machine will automatically reboot to complete the installation.

Finally you will be greeted with the Ubuntu log-in screen where you can enter your username and password defined during the initial setup (don’t forget that the default password is ‘changeme’ if you left everything as the default).

Explore Virtual Box

Duration: 1:00

Enjoy your shiny new Ubuntu Desktop!

As always we recommend opening a terminal and running sudo apt update && sudo apt upgrade -y and then sudo snap refresh to get everything updated to the latest versions.

Once you’ve finished your session you can close your machine by clicking the X in the top right of the window and choosing whether to keep your machine frozen in its current state or shut it down completely.

As you can probably tell, there are tonnes of further configuration options available in VirtualBox and we’ve only scratched the surface.

VirtualBox allows you to create and configure multiple virtual machines, so don’t be afraid to create new instances of Ubuntu to try out different system and storage configurations to fine tune your performance.

Why not try following the tutorial above with one of the Ubuntu flavours!

Tell us your thoughts!

Duration: 1:00

Thank you for following this tutorial, we’d love to hear how you got on.

Give us feedback in the Ubuntu Discourse if you have any issues.

To help us improve our tutorials, we’d love to hear more about you:

How will you use this tutorial?

  • Only read through it

  • Complete the exercise

0 voters

What is your current level of experience?

  • Novice

  • Intermediate

  • Proficient

0 voters

What operating system are you following this tutorial on?

  • Ubuntu

  • Other Linux OS

  • Windows

  • Mac OS

0 voters
3 Likes

What boggles me is that when using Fedora in the same VirtualBox application, it doesn’t need such settings to be applied. User is free to resize VB window and VM inside adjusts its resolution on the fly. And it has never worked with Ubuntu in VB.
In case of Fedora Plasma, resizing of VM’s doesn’t work that way but applying another resolution in Systemsettings does.

Yeah it’s not a great first experience, the only other option is to complete the installation at 800x600 then install guest additions. We should investigate.

Before starting the VM, I would recommend to click on Settings > System > Processor and drag the processor count from 1 to the max of the green area. In my case this is 4. This creates a more pleasant initial installation experience.

hello, tutorial tells allocate 10 gb of memory, but for Ubuntu 22.04.1 LTS it is not enough and for installation process occurs error error installing linux-image-5.15.0-46-generic

1 Like

Can someone please have notation on the difference between virtualbox- additions and virtualbox-additions hwe:-)
Greatly appreciated
William Higinbotham, Seminole, FL

Ubuntu 22 LTS : space disk is not enough. df -h | grep sda you can see one of sda is 98% occupied.
No luck either with the addon’s which won’t install. I followed this : https://askubuntu.com/questions/514829/virtualbox-guest-additions-wont-install/514838#514838
I haven’t fixed the space disk error yet. It’s been more than a week that I do install. I guess I’ll just change of os ! Maybe I’ll give another try if someone answer these posts. Otherwise the tutorial is very clear.

Hey folks, I’ve given this tutorial a fresh coat of paint with the release fo VirtualBox 7 and unattended installs :slight_smile:

2 Likes

Hi there! I think this tutorial may need to mention adding your first user to sudoers if the user has opted to use the unattended install. (See also this superuser Q&A.) This doesn’t happen automatically, and it might be frustrating to users trying to follow the update instructions in step 4. Thanks :slight_smile:

3 Likes

In the “Explore Virtual Box” section it mentions “recommend opening a terminal”.
However, I followed the instructions in the previous sections, and the terminal does not work out of the box. Opening the terminal application will give a spinning mouse cursor for 30 seconds and then not open the terminal.
To actually get a working terminal you need to follow the instructions here:
https://askubuntu.com/questions/608330/problem-with-gnome-terminal-on-gnome-3-12-2/991047#991047
To type in these instructions you can use Ctrl-Alt-F3 to get to the TTY, where you can enter the commands. To get back to the GUI you can use Ctrl-Alt-F2. The specific F-number may be different on your install.

The default locale of the unattended installation is en_US.
Running “sudo dpkg-reconfigure locales” and selecting en_US.UTF-8 fixes the problem after a reboot.
See above comments on how that is already a challenge as the unattended installation also fails to add your user to the sudo group. You can install another terminal like “terminator” through “Ubuntu Software” to fix those problems. In general i can’t recommend this guide in the current form. My advice is not to use the unattended option at all until Oracle fixes those bugs.

https://forums.virtualbox.org/viewtopic.php?f=3&t=108262

1 Like

I suggest skipping “Unattended Installation” to avoid the issue of failure of starting Terminal when you use your account. Details on the page below:

https://askubuntu.com/questions/1435918/terminal-not-opening-on-ubuntu-22-04-on-virtual-box-7-0-0

There’s probably a spelling mistake in the very first line of this paragraph. The word “greated” will be replaced by the word “greeted.”
Thank You.

1 Like

I followed the guide, and I ended up with a user called “vboxuser” and I couldn’t “sudo apt install git” because the user is not in the sudoers file. I also couldn’t “apt install git” for permission reasons. Did this happen to anyone else? Did I do a step incorrectly?

Edit: this solution worked https://askubuntu.com/a/1440054

Should it be added to the guided steps? Ubuntu is pretty much unusable without sudo access.

1 Like

Does this issue occur if you configure a different user in the ‘Create user profile’ step? Or only if you leave it as default?

If creating a user without the defaults gives you sudo access I would rather update the tutorial to highlight more explicitly that these values should be changed, rather than adding the default user to the sudoers file after install (which is probably a deliberate move on VB’s part to avoid potential security issues)

Tried this with Ubuntu 23.04. Does not work!
Tried again with 22.04 LTS. Works!

This is likely due to the new installer code-base used in Ubuntu 23.04 that is affecting the ‘unattended install’ setup in Virtual Box. I would try using non-guided install and seeing if that works.

Hello Everybody,

I carried out this lab on Ubuntu 22.04 LTS, as I had to install Ubuntu 18.04 LTS. However, I faced issues when I downloaded VirtualBox v7 from site. To every one trying to install VirtualBox v7 for this lab, kindly follow site.

Once I installed VirtualBox v7, then everything worked like a breeze.

Oh! I forgot to tell you that I used unattended installation.

Thank you :slight_smile: