Running Ubuntu in VirtualBox on Windows/Mac [Tutorial]

Running Ubuntu In VirtualBox

Here’s a straightforward set of instructions (with lots of screenshots) on how to set up Ubuntu Linux in VirtualBox for running Ubuntu in a Virtual Machine on Windows 10 and macOS.

VirtualBox allows you to set up and run virtual machines on your computer easily.  A virtual machine is a whole computer, virtualized running on top of your current operating system – allowing you to try out and experiment with new operating systems and tools without reformatting your computer.

Download and Install Virtualbox

The first step: head to the Virtualbox website to download VirtualBox:

https://www.virtualbox.org/

ubuntu virtualbox 2

Click on the big ‘Download’ button to download Virtualbox

ubuntu virtualbox 3

Then, select the package for your computer’s operating system – in my case Windows.

Once downloaded, run the VirtualBox installer.  If you’re on macOS, things will look a bit different, but the steps will be largely the same.

ubuntu virtualbox 1

Click yes to acknowledge that you might lose internet for a few moments during the install.

ubuntu virtualbox 4

ubuntu virtualbox 5 1

The default install options are all fine for our purposes.

ubuntu virtualbox 6

ubuntu virtualbox 7

Click ‘Install’ when you’re ready to go.

ubuntu virtualbox 9

You’ll see a bunch of prompts to install VirtualBox drivers – click ‘Install’ for each. Whether or not you want to be prompted for every further drive from Oracle is up to you – I prefer not to select ‘Always Trust’ so that I know what’s being installed on my system.

ubuntu virtualbox 10

ubuntu virtualbox 11

ubuntu virtualbox 12

VirtualBox is installed! Click ‘Finish’ to continue and launch VirtualBox.

Download Ubuntu

To download Ubuntu, visit:

https://ubuntu.com

…navigate to the downloads section and click on the big green ‘Download’ button.

I recommend Ubuntu Desktop for beginners as it has a graphical interface and a bunch of pre-installed software to help you get started.

ubuntu virtualbox 14

Create & Configure a Virtual Machine in VirtualBox

ubuntu virtualbox 13

Back to the VirtualBox window, click the ‘New’ Button to create a new virtual machine.

ubuntu virtualbox 15

Fill out the name for your virtual machine and select the Type and Version to match the version of Ubuntu you have downloaded. The machine folder can be left at the default.

ubuntu virtualbox 16

Select the amount of RAM the virtual machine should have. 1024MB (1GB) is the bare minimum; you should probably use at least 2048MB if your computer, which is running VirtualBox, has more than 4GB of RAM.

ubuntu virtualbox 17

Leave the option to create a new virtual hard disk at the default and hit ‘Create.’

ubuntu virtualbox 18

Again, the default option ‘VDI’ is the one we want here.

ubuntu virtualbox 19

Keep the default ‘Dynamically allocated’ option and continue.

ubuntu virtualbox 20

Select the size for the virtual hard disk your Ubuntu virtual machine will use. At least 20GB is recommended (if you have space). As it will be dynamically allocated, it won’t use up this space all at once – the virtual hard disk will grow in size as needed until the 20GB limit is reached.

Start the Virtual Machine and Install Ubuntu

The virtual machine is now configured – let’s install Ubuntu!

ubuntu virtualbox 21

Now that the virtual machine is created, the main VirtualBox window will show again. Click the green ‘Start’ button to start the new virtual machine.

ubuntu virtualbox 22

You’ll be prompted for a startup disk – this will need to be the Ubuntu install disk image previously downloaded. Click on the folder icon to choose it.

ubuntu virtualbox 23

You’ll be presented with a window to choose which disk to load – click on ‘Add’ to add the Ubuntu disk to the list.

ubuntu virtualbox 24

Navigate to the downloaded Ubuntu disk image location and select it, then click ‘Open.’

ubuntu virtualbox 25

The Ubuntu installer will now appear in the list – select it and then click ‘Choose.’

ubuntu virtualbox 26

Click ‘Start’ to start the virtual machine with the chosen disk image.

ubuntu virtualbox 27

The Ubuntu installer will boot automatically after running a few checks. VirtualBox will display some warnings about mouse/keyboard integration. They can be dismissed.

ubuntu virtualbox 28

When the installer is ready, click ‘Install Ubuntu and follow the prompts.

ubuntu virtualbox 29

Select your keyboard layout.

ubuntu virtualbox 30

Choose your installation options – the defaults should be fine.

ubuntu virtualbox 31

As we’re using a new virtual hard disk with no data on it, the default option of erasing it is fine.

ubuntu virtualbox 32

ubuntu virtualbox 33

Select your location.

ubuntu virtualbox 34

Fill out the details for the Ubuntu user account. Choose a secure password – this account will have administrative rights.

ubuntu virtualbox 35

The installer will then complete the installation while displaying some helpful messages.

ubuntu virtualbox 37

When it’s done, you’ll be prompted to restart the virtual machine.

ubuntu virtualbox 38

The installation disk image will have been automatically disconnected, so go ahead and press ENTER to continue.

Logging in to New Ubuntu Virtual Machine For the First Time

Ubuntu is now installed – let’s see what it can do!

ubuntu virtualbox 39

The Ubuntu loading screen. Further mouse/keyboard integration warnings can be dismissed.

ubuntu virtualbox 40

Click on your username to log in.

ubuntu virtualbox 41

ubuntu virtualbox 42

On the first run, you’ll see many welcome screens giving you the option to connect various accounts. Ignore or use them as you see fit.

ubuntu virtualbox 43

ubuntu virtualbox 44

ubuntu virtualbox 45

ubuntu virtualbox 46

ubuntu virtualbox 47

Go ahead and install any updates if prompted. Staying up to date is a good thing.

ubuntu virtualbox 48

The Ubuntu desktop ready to use (almost).

Installing VirtualBox Guest Additions in Ubuntu

We’re almost there – Ubuntu is ready to use, but you’ll probably notice it’s in a window that doesn’t fill your screen.  Installing the VirtualBox Guest Additions in Ubuntu will add support for dynamically resizing the Ubuntu desktop to fit whatever size you drag the VirtualBox window to, or even go full screen.  It also adds the ability to share folders with your virtual machine along with a bunch of other useful stuff.

ubuntu virtualbox 57

First, we need to install some dependencies that VirtualBox Guest Additions require. Open the terminal by clicking on the dots in the bottom-left of the screen and searching for ‘Terminal,’ and clicking on the icon.

ubuntu virtualbox 59

Once the terminal is ready, run the following commands:

sudo apt update

sudo apt install build-essential gcc make perl dkms

This will install the packages the VirtualBox Guest Additions installer requires.

ubuntu virtualbox 60

Enter Y to confirm the installation of the dependencies if prompted.

ubuntu virtualbox 49

Next, in the VirtualBox window, click on the ‘Devices’ drop-down and select ‘Insert Guest Additions CD Image.’

ubuntu virtualbox 50

Open the file browser by clicking on the folder icon in the left menu bar and then click on the newly inserted disk image in the left panel.

ubuntu virtualbox 61

If you aren’t automatically prompted, click the ‘Run Software’ button in the top right of the file browser, then click ‘Run’ to run the installer.

ubuntu virtualbox 52

Enter your password if prompted.

ubuntu virtualbox 62

You’ll see a bunch of text fly by while the installer does its thing.

ubuntu virtualbox 63

When done, you’ll get a message about restarting your computer and be asked to press Return to close the window – do so.

ubuntu virtualbox 55

Final step – restart! Click on the down-arrow icon in the top-right of the screen and then click ‘Power Off.’

ubuntu virtualbox 64

…Then click ‘Restart.’

All Done!

Your Ubuntu virtual machine is now ready to use – and the screen will resize to fill the screen on the Windows 10 or Mac computer hosting it.

ubuntu virtualbox 65

ubuntu virtualbox 66

Once you’re up and running, be sure to visit LinuxScrew in your new Ubuntu virtual machine if you need any tips on using your new OS.

SHARE:
nv-author-image

Brad Morton

I'm Brad, and I'm nearing 20 years of experience with Linux. I've worked in just about every IT role there is before taking the leap into software development. Currently, I'm building desktop and web-based solutions with NodeJS and PHP hosted on Linux infrastructure. Visit my blog or find me on Twitter to see what I'm up to.

Leave a Reply

Your email address will not be published. Required fields are marked *