Knowledge for the World

How to set up Linux on your PC using a virtual machine

If you are using Windows on your PC, it may be easier to code or program by running Linux or another Unix-based operating system alongside Windows. There are a few ways to do this including: dual-booting, containerization, or using a virtual machine.

This guide will focus on how to set up Linux using a virtual machine. A virtual machine uses your current computer and software to emulate a second computer, all within the same physical device. When you run Linux (the guest OS) alongside, say, Windows (the host OS) you can create two operating systems in one device. The virtual machine functions separately from its own window, although it is possible to switch back and forth between the guest and host OS, such as for transferring files or taking snapshots.

There are many different applications you can download and use to run virtual machines, however one that is recommended is Oracle VirtualBox.

1

You can download either the 64 or 32-bit version. Most modern computers have a 64-bit architecture. If your computer is very old, you may require 32-bit.

If 64-bit does not appear on the dropdown menu, you may have to enable virtualization through an advanced reboot. If you have an HP laptop, here is one resource which might be helpful.

2

As you click “next” through the installation process, you will see a number of prompts, the first of which is to decide which components you would like to install. I recommend leaving the default options selected.

The Custom Setup screen on the next page asks which folder you would like your VirtualBox to appear in. You may also be asked at some point for antivirus and firewall software permission and make sure to allow permission.

3

Create a virtual machine

Once you have opened Oracle VirtualBox, click on the “New” icon in the toolbar. You will be asked to provide a name for your virtual machine, which you can enter in the “Name” box.

Select “Linux” as the type and “Ubuntu” as the version (making sure to select 32-bit or 64-bit depending on your host computer).

4

After clicking “next”, you will be asked to select how much memory you would like to give to the virtual machine. Do not go below the minimum specified, and also you must be remember to leave enough memory for the host operating system, in this case Windows, to keep running.

5

This process allocates disk space to the virtual machine. First select “Create a virtual hard drive now”. Then click “Create”. The default VDI file type is native to VirtualBox, so you can select “VDI”.

You can choose to use a fixed size hard drive or a dynamically sized hard drive. I recommend a fixed sized disk if you have enough disk space, because it won’t increase the file size as required. Next you will be asked to specify how much disk space you will devote to the Ubuntu Virtual Machine. Do not go below the minimum set. A recommended size is 15 gigabytes.

6

Start the virtual machine

You can start the virtual machine by pressing the “Start” button on the toolbar. The first boot will require you to select a disk. You can do this by clicking the folder icon, navigating to the downloads folder, and selecting Ubuntu ISO. Then click start.

You will then be given the option to Try Ubuntu or Install Ubuntu. It is recommended to install however you can always install it later from the desktop if you choose to try it out first.

This article goes into more detail regarding settings upon installation, such as whether to install updates as you go or install 3rd party software.

7

Select “Erase disk and install Ubuntu”. Then click “Install now”. Remember you are not installing on a real hard drive, so this will not affect your host operating system.

Lastly, choose your location, keyboard layout, and create a user. When you create a user you will be asked for your name, a name for your virtual machine, a username, and a password. Reboot your machine to finish the installation.