Skip to content

Instantly share code, notes, and snippets.

@ga-wolf
Created March 12, 2018 04:10
Show Gist options
  • Save ga-wolf/92d810797bfbd8ea619827034719b4d0 to your computer and use it in GitHub Desktop.
Save ga-wolf/92d810797bfbd8ea619827034719b4d0 to your computer and use it in GitHub Desktop.
Installing a Ubuntu Virtual Machine on a Windows Computer

Installing a Ubuntu Virtual Machine on Windows

This tutorial is targetted at installing a Ubuntu Virtual Machine on a Windows computer.

Some Terminology

  • A Virtual Machine (VM) is a fancy program that emulates computers
    • Why would you use them? Great for developing and testing software on different platforms, offers extraordinary amounts of flexibility, great for businesses (because you have full control - it can save you money, make maintenance easier, allow for remote workstations, plus they can be manipulated, started and stopped instantly)
    • The downsides... They aren't nearly as fast. You do still have to pay licensing fees for software that requires that (things like Windows 10 for example), the support isn't quite as good for certain hardware components, there can be network constraints, and there is an additional layer of debugging if something goes wrong
    • Ideally you don't have to use them
  • The HOST machine is your normal operating system (whatever you normally use, e.g. Windows)
  • The GUEST machine is the operating system that is running/going to be run in Virtual Box (e.g. Ubuntu) One important thing, the HOST machine is your normal operating system (whatever you normally run e.g. Windows), the GUEST machine is the operating system that is running in Virtual Box (e.g. Ubuntu)

Process

1. Download and Install

  • Download the Ubuntu ISO file
    • Visit this page
    • Hit Download on the latest version (I didn't use LTS - this stands for Long-Term Support)
    • Decide whether you want to pay or not
      • If you want to pay, click "Pay with PayPal" and follow the prompts
      • If you don't want to, click "continue to the download" or "not now, take me to the download"
    • Start the download and save the file in a place that you will remember (e.g. Downloads file)
    • While you are waiting for this download, you can continue on with the following steps
  • Visit the Oracle Virtual Box page
  • Click the link for the latest appropriate platform package (currently the latest is 5.2.8). Note, by appropriate I mean the same as your operating system - e.g. if you are on a Windows computer, select Windows Host
  • Once you have clicked that, save the file into a place you'll remember (e.g. your Downloads folder)
  • Run that file (double-click the file), follow the prompts and install the application
  • Once installed, open up the VirtualBox app

2. Create a Virtual Machine

  • Find out if you have a 64-bit or 32-bit CPU
    • Follow the steps here
  • In the VirtualBox application, click the New Icon
  • Define the Name and Operating System
    • Set the name to something appropriate, e.g. "Linux (Ubuntu 64-bit)" (change 64 to 32 if you are on a 32-bit CPU)
    • Set the type to "Linux", or whatever is appropriate
    • Set the version to "Ubuntu" 64-bit, or whatever is appropriate (change 64 to 32 if you are on a 32-bit CPU)
    • Click "Continue"
  • Allocate the RAM for this Virtual Machine (Memory Size)
    • Pick no less than the recommended, the higher you go, the faster it will be (though stay within the green section)
    • I picked 4096mb
    • Click "Continue"
  • Create the Hard Disk
    • Select "Create a virtual hard disk now"
    • Click "Create"
    • Define the Hard Disk File Type
      • You must have downloaded the Ubuntu ISO file (or whatever OS you are installing) by this point. If you haven't, wait for the download to complete or go back and start it (it is in "1. Download and Install")
      • Select "VDI (VirtualBox Disk Image)"
      • Click "Continue"
      • Select "Dynamically Allocated"
      • Click "Continue"
      • Select the File location and size. Make sure the size is at least 10.00GB
      • Click "Create"

3. Start the Virtual Machine for the first time

  • Select the appropriate Virtual Machine in the VirtualBox app (e.g. "Linux (Ubuntu 64-bit)")
  • Press the "Start" button
  • This will open up the actual VirtualMachine, now we need to tell it where the Operating System is
    • Press the folder icon, and select the ISO file you downloaded earlier (e.g. the Ubuntu 64-bit ISO file in your Downloads folder)
  • Once selected, press the "Start" button
    • This will take a while

4. Install the OS

  • After starting your Virtual Machine, you should be presented with a Welcome Page
  • Select your desired language, e.g. "English"
  • Click "Install Ubuntu"
  • Select "Download updates while installing Ubuntu"
  • Click "Continue"
  • Select "Erase Disk and Install Ubuntu" - note, this is just for the VM
  • Click "Install Now"
  • When prompted with "Write the changes to disks?", click "Continue"
    • This will take a while
  • Answer the "Where are you?" question, e.g. "Sydney"
  • Click "Continue"
  • Select your keyboard layout, e.g. "English (US)"
  • Select "Continue"
  • Answer the "Who are you?" part
    • Type in your name
    • This will generate "Your computer's name" and "Pick a username"... Remember these! Particular your username - we will be using that later
    • Type in your password
    • And decide whether you want to log in automatically or require your password
      • I normally require my password
    • Click "Continue"
    • This Installation will take a fair while
    • Once the installation is complete, click "Restart now"
    • Then when prompted with "Please remove the installation medium, then press ENTER", press "Enter"

5. Install Guest Additions

  • Close your Virtual Machine by clicking the red button, or the cross at the top and selecting "Power off the machine"

  • Login to your account

  • Click the Devices menu icon on your HOST machine, then click "Insert Guest Additions CD Image..."

  • "Click run" and type in your password then press "Authenticate"

  • When prompted with "Press Return to close this window", hit the Enter or Return Key

  • Once this has been done, open up the Terminal application

    • Hit the menu icon in the bottom left (9 dots), and double click the Terminal Application (you may have to scroll down - it will look something like this >_)
    • We are going to authenticate your user profile with Virtual Box, so run this command in the terminal
      • sudo adduser YOUR_USERNAME vboxsf
      • Type in your password and wait for it to complete (note that you won't be able to see yourself typing when entering the password)
      • Restart your virtual machine (hit the Arrow Icon in the top right, hit the power icon and select "Restart")
    • Now, we need to install some command line tools. Run this in the terminal:
      • sudo apt-get install gcc make perl
      • When prompted with "Do you want to continue? [Y/n]", Type "Y" and hit "Enter"
    • Now, we need to run the installer for GuestAdditions
      • Run cd /media/YOUR USERNAME/VBox_GAs_5.2.8/ (replace 5.2.8 with your version number). You can use tab completion for this! Once you have typed cd /media/ just start hitting tab and it will fill in the path
    • Run the installer!
      • sudo ./VBoxLinuxAdditions.run

6. Set up Shared Folders

This is so you can share folders between your operating systems.

  • On your Host Machine, create folder that you would like to share somewhere memorable (e.g. a folder called "Shared" in your "Documents" folder)
  • On your Host Machine, in the VirtualBox application, select your Virtual Machine (e.g. "Linux (Ubuntu 64-bit)") and hit the settings icon
  • Hit the Shared Folders Icon
  • Hit the Folder with the plus on it to add a Machine Folder
  • Add the foler path by hitting the arrow and select the folder you created earlier (e.g. your "Shared" folder)
  • Leave the Folder Name alone
  • Select "Auto-mount"
  • Select "Make Permanent"
  • Click "OK"
  • Hit "OK" again
  • Restart your Virtual Machine
  • Open up the Terminal application in your Virtual Machine
  • In the terminal, run cd /media/sf_Shared (replace the Shared with whatever the folder name from before was). This is now a folder where both operating systems can access files
    • You'll have to cd into this folder most times you want to use this Virtual Machine - so make sure you remember that command (tab completion will help)

7. Set up Port Forwarding

  • Back on the Host Machine in the Virtual Box Application, select your Virtual Machine and click the settings icon
  • Go to the Network tab
  • Make sure Attached to is set to NAT
  • Click the Advanced arrow
    • Press the Port Forwarding button
      • Add rules by pressing the plus icon
        • The first rule you'll create... Leave everything empty, except set the Host Port and Guest Port to 3000
        • Do the same thing for the numbers 3001, 4567, 8000, and 8080

8. Enable Shared Clipboard

  • Back on the Host Machine in the Virtual Box Application, select your Virtual Machine and click the settings icon
  • Go to the General tab
    • Click the Advanced tab
    • Set "Shared Clipboard" to "Bi-directional"
    • Click "OK"

9. Some final things

  • Is your Virtual Machine's screen flickering?
    • Open up the Virtual Machine's terminal
    • Run the following command:
      • sudo perl -e '$^I=".backup";while(<>){s/#(WaylandEnable=false)/$1/;print;}' /etc/gdm3/custom.conf
    • Restart the Virtual Machine
  • If the software updater comes up, you don't have to download the updated software right away, so feel free to press "Remind me later", but if you have a decent Internet Connection - you might as well hit "Install now"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment