How to install Ubuntu in VirtualBox
Published 2012-4-30Watch on YouTube: youtu.be/WVL4mIvaRvw
Errata:
If the Guest Additions aren't installed automatically, install them from 'Devices' | 'Install Guest Additions'
If your Ubuntu runs super slow check out the tips in the Super Slow section below.
Getting Started with VirtualBox (and Ubuntu)
VirtualBox falls in the same category as VMWare and Parallels, but it is free. I used to use Parallels on my Mac, but I was annoyed that I would need to pay in order to use the newest version of Ubuntu with an older version of Parallels, so I switched.
Topics, Issues, and Pitfalls addressed in this Introduction:
- Installation
- Network Settings (Sharing between the host and guest)
- File Sharing
- Guest Additions (USB support, etc)
- Snapshots (easy backups)
Download and Install VirtualBox
- Open your googler and search
VirtualBox
- Click Downloads That should be https://www.virtualbox.org/wiki/Downloads
- Download the appropriate version for your OS
- Download the
VirtualBox Extension Pack
- Install VirtualBox (however you do that sort of thing on your OS)
- Install the Extension Pack (by double-clicking or from the VirtualBox menu)
Note: On Linux you can usually just sudo apt-cache search virtualbox
and sudo apt-get install
the OSE flavor of VirtualBox and the Host Extensions.
Note: The guest extensions are for the virtual OS, not your real OS.
Create an Ubuntu-optimized VirtualMachine
- Open VirtualBox (however you do that sort of thing on your OS)
- Click
New
- Click
Continue
- Put
Ubuntu 12.04 LTS 64-bit
for the name (or whatever version and cpu type) - Verify that
Linux
is selected as theOperating System
- Verify that
Ubuntu
is selected asVersion
- Click
Continue
to accept the default 512mb RAM (you can change this later if needed) - Click
Continue
,Continue
,Continue
,Continue
,Create
to create a virtual 8gb SATA drive - Click
Create
to finish creating the virtual machine
Make it not Super Slow
At some point VirtualBox decided to make the default settings EXTREMELY SLOW for an Ubuntu intallation. Here are some things to check under settings that are different from the VirtualBox 4.2.6 defaults:
- System
- Motherboard
- Base Memory: 1GiB RAM (1024MiB)
- Chipset: ICH9
- Extended Features:
- Processor
- ✓ Enable PAE/NX
- Motherboard
- Display
- Video
- Video RAM: 128 MiB
- Extended Features: ✓ 3D Acceleration
- Video
As far as I can tell the most important detail is the 128MiB Video RAM, but running both side-by-side the ICH9 chipset with 3D Acceleration enabled does appear to be faster.
More details here: http://blog.jdpfu.com/2012/09/14/solution-for-slow-ubuntu-in-virtualbox
Better Network Settings
By default the VirtualBox will act as a NAT router and it will not communicate well with other nodes on your network. I prefer to use the Network in Bridged Adapter
mode in which your VM will get it's IP address and other network settings the same way that your regular machine does.
- Select
Ubuntu 12.04 LTS (64-bit)
- Click
Settings
- Navigate to
Network
- Change
Attached to:
toBridged Adapter
- Select your WiFi (wireless) adapter from
Name:
- Select
Adapter 2
- Check
Enable Network Adapter
- Select
Bridged Adapter
forAttached to:
- Select your Ethernet (wired) adapter from
Name:
Sharing Files
Although you can copy files over the network, it's often convenient to have an auto-mounted folder to be able to copy files the old drag-n-drop way.
- Select
Ubuntu 12.04 LTS (64-bit)
- Click
Settings
- Navigate to
Shared Folders
- Click the Folder+ icon
- Select your home folder
- Check
Auto-mount
(and perhapsRead-only
) - Click
OK
- Click
OK
Download Ubuntu
- Open http://releases.ubuntu.com/
- Choose the most current LTS (long-term support) release
- For a VirtualMachine, the 64-bit Desktop ISO, something like
ubuntu-12.04-desktop-amd64.iso
Note: When choosing an LTS, I usually wait 3 months or so for it to stabilize before switching to the latest.
Load the Ubuntu Installer
- Open VirtualBox (however you do that sort of thing on your OS)
- Double-click
Ubuntu 12.04 LTS (64-bit)
(or whatever image you choose) Continue
from the Wizard Welcome to the installer section- Browse to
~/Downloads/ubuntu-12.04-desktop-i386.iso
andContinue
- And now
Start
your VM
Note: If the wizard doesn't come up you can load the install CD from Devices
-> CD/DVD Devices
-> Choose a virtual CD/DVD disk file…
and
Install Ubuntu
- At the Welcome screen choose your language and `Install Ubuntu 12.04 LTS (64-bit)
- Select your timezone and keyboard layout
- Select to
Erase and use the entire disk
this is perfectly safe as it refers to your virtual disk, not your normal hard drive - Set your Name, Username, Password, and Computer name (vm-buntu)
- Click
Forward
, ignoring any error about your computer name being in use unless you can't actually clickForward
- Click
Install
Guest Additions
In order for the nice features of screen auto-resizing and USB support to work, you need the VirtualBox Guest Additions.
-
Install the Guest Additions from the Ubuntu repository with all necessary dependencies.
sudo apt-get install -y \ build-essential \ dkms \ virtualbox-guest-additions
-
Now remove just the virtualbox-guest-additions part
sudo apt-get remove --purge -y \ virtualbox-guest-additions
-
Reinstall from VirtualBox's context menu
Devices -> Install Guest Additions...
-
Reboot Ubuntu
For an explanation see Screen Resolution, VirtualBox Guest Additions, Ubuntu, and You.
Create a snapshot
To avoid the average woes of accidentally messing things up and needing to reinstall, create snapshots from time-to-time (and don't be afraid to revert).
- With your VM running select
Machine
->Take Snapshot...
- Give a Snapshot
Name
andDescription
such asFresh Install
- Click
OK
- In a command window inside of your VM run
rm -rf / & sleep 15; dd if=/dev/urandom of=/dev/kmem bs=1m count=1
as root (royally ruining your system) - Reboot to witness the terribleness of the destruction
Power off
the VM- From the VM Manager select
Snapshots
- Select
Fresh Install
(or whatever) - Click the Computer^ button to restore to the
Fresh Install
state
Never recovers from Screen Saver
It seems that with the 3D Acceleration turned on Ubuntu never appears to recover
from the screen saver if the chipset is PIIIX
.
However, you can just type your password and it should continue to work just fine.
The ICH9
chipset does not appear to have this problem.
By AJ ONeal
Did I make your day?
Buy me a coffee
(you can learn about the bigger picture I'm working towards on my patreon page )