1 Objective

You will install VirtualBox on your laptop, create a VM, and install a guest operating system.

Note: the files you will need (VirtualBox software and ISO images) will be provided either on a USB stick or on the workshop web server. Please don't download large files directly from the Internet.

The USB stick is preferred as it will be faster than the shared wireless.

If your laptop has less than 1GB of RAM or less than 5GB of spare disk space, please check with the instructors if it will be suitable.

2 Install VirtualBox

Separate instructions follow for Mac OSX, Windows and Linux. Once you have installed VirtualBox, move onto the section entitled "Create a Virtual Machine".

2.1 For Mac OSX

Double-click on the disk image file VirtualBox-x.x.x-xxxxx-OSX.dmg

Double-click on VirtualBox.pkg and follow the installer.

Open the Applications folder and double-click on VirtualBox. You can lock its icon onto the Dock to make it quicker to find in future. The Host Key by default is the Left Cmd key.

2.2 For Windows

Double-click on the executable VirtualBox-x.x.x-xxxxx-Win.exe and follow the install wizard with default settings. Give it permission to install the device drivers.

Start VirtualBox using the icon on the desktop or in the start menu.

Note: if you have Windows 8 and have enabled Hyper-V, you will need to disable Hyper-V before VirtualBox can work.

2.2.1 Checking VT-x

VirtualBox doesn't require VT-x or AMD-V (except when running 64-bit guests), but it will work faster with it.

You can check whether hardware virtualization is enabled on your laptop by downloading and running the Hardware-Assisted Virtualization Detection Tool

If it says "this computer does not have hardware-assisted virtualization" then your laptop may be so old that it does not have this feature, or it could just be disabled in the BIOS.

Restart your laptop, go into BIOS Setup, then look for a setting which may be under "Advanced BIOS Features" or "Security".

Virtualization Technology (VT-x)

Ensure it is set to Enabled. (If you see VT-d, you can turn that on as well, but it's only important if you want to give your guest VM direct access to some of the host hardware)

After changing this setting and saving, some systems require you to fully power off and power on again.

In extreme cases you may need to https://forums.virtualbox.org/viewtopic.php?p=108857

2.3 For Linux (Ubuntu 12.04)

Copy the appropriate file for your operating system:

Install it by double-clicking, or from the command line using this command:

$ sudo dpkg -i virtualbox-x.x_x.x.x-xxxxx~Ubuntu~precise_xxx.deb

Start the GUI by typing "VirtualBox"

To check whether your laptop has VT-x, at a command line type

$ egrep '(vmx|svm)' /proc/cpuinfo

If you see at least one line containing vmx or svm, the CPU has this capability, although it is not necessarily enabled in the BIOS.

3 Create a virtual machine

You are now going to create a virtual machine and install Ubuntu inside it.

You will install Ubuntu Server Edition, as it is faster to install than the Desktop Edition, and will give you an opportunity to practice administering a system using the command line.

The 32-bit (i386) version is fine because we do not expect to give this VM more than 4GB of RAM. For a real server you would more likely install the 64-bit (amd64) version instead.

Find the appropriate Ubuntu ISO image (e.g. ubuntu-12.04.3-server-i386.iso). Make a folder on your laptop for ISO images, and copy the Ubuntu ISO image there.

3.1 New Virtual Machine

In the VirtualBox Manager window, click on the "New" button (a blue spiky circle)

The first screen asks for Name and operating system


The next screen is the memory size. Accept the default of 512MB, unless your machine is very limited on RAM. You can change this later.

The next screen asks for Hard drive. Select "Create a virtual hard drive now" and click "Create"

Select the default VDI (VirtualBox Disk Image) and click Next.

Choose "Dynamically allocated" and click Next. (This option allocates disk space only when the guest OS writes to the virtual disk)

Accept the default size of 8.00 GB. Note that this won't actually use 8GB straight away on your laptop, but will allow it to grow up to 8GB. Click Create.

Now you will see the VM created but in state "Powered Off"

3.2 Insert virtual CD

When you start a VM for the first time, VirtualBox will automatically prompt you for a CD-ROM image. However you are going to do it the manual way so that you learn your way around the settings.

Before starting the VM, click on the "Settings" button (an orange sprocket)

Click on Storage.

You should see:

Click on the CD icon by "Empty". To the right you will see:

Click on this other CD icon. From the menu which appears, select "Choose a virtual CD/DVD disk file..."

Browse to the directory where you copied the ubuntu server ISO image, and select it.

You should now see:

Click OK.

3.3 Start the VM

Select the VM and click the green Start arrow - or simply double-click the VM - and your VM will start.

You may get some warnings - read them. One will read something like this:

"You have Auto capture keyboard option turned on ... You can press the host key at any time to uncapture the keyboard and mouse and return them to normal operation ... The host key is currently defined as Right Ctrl"

Have a look at the bottom right-hand corner of the window. It should show a reminder of what the host key is set to, next to a small downward arrow.

The Ubuntu installer should start. Click inside the window. Note that you have to press the host key to get your mouse out again.

If this is the first time you've installed Ubuntu, ask a neighbor or an instructor for help if you get stuck.

Select your language, and press F3 if you want to select a non-US keyboard layout.

Next, press F4 and select "Install a minimal virtual machine".

This selects the minimum number of packages to get a very basic system.

Then select "Install Ubuntu Server" from the front menu, and follow the prompts. Use Tab to move around the screen, Enter to select something.

Follow the prompts for timezone, keyboard and so on. It's quickest to say "No" when asked if you want to auto-detect the keyboard layout; you can then manually select the US English layout or whichever is appropriate.

Use whatever hostname, username and password you like. This is your own VM to take away and keep! Ask your neighbor or an instructor if you need help.

We do strongly suggest the following settings:

3.4 Restart

Once the installation is complete, you will be prompted to restart.

If the machine starts up with the virtual CD-ROM still attached, you may need to remove it. Go to Settings > Storage as before, click on the CD icon under Controller IDE, click on the second CD icon, select "Remove disk from virtual drive". Then restart the VM again.

After a few seconds you should get an Ubuntu login prompt. Login with the username and password you created.

3.5 Try the console

You a sitting in front of a server text console. Just like on a real PC, you can switch between virtual consoles using Ctrl-Alt-F1 to Ctrl-Alt-F6.

Here are a few basic commands you can try: the "$" is the prompt you will see, so don't type it.

$ uptime        # how long machine is running, how busy it is
$ uname -a      # information about the kernel
$ df -h         # free disk space in (h)uman readable form
$ ls /          # list the root directory

3.6 Mouse cursor

If you want a mouse cursor in Ubuntu Server, you need to install the package "gpm". These commands need to be run with "root" or superuser privileges, so you prefix them with "sudo".

$ sudo apt-get update          # update the index of downloadable packages
$ sudo apt-get install gpm     # install the package

Once you've done this, you should be able to copy-paste within your VM by using the left and right buttons to select, and middle button to paste.

If you want to be able to copy-paste between the VM and your laptop, see the optional exercises at the end.

3.7 ACPI shutdown

Try selecting Machine > ACPI shutdown from VirtualBox, and you should see that this triggers the virtual machine to shut itself down. It takes only a couple of seconds. Then you can restart your virtual machine.

If nothing happens, it could be because your server doesn't have an acpi daemon installed to respond to the request. If so, you can install it like this:

$ sudo apt-get install acpid

4 Additional exercises

If you complete the basic Ubuntu install early, here are some additional things you can do, as well as exploring the Ubuntu install you've just done.

4.1 Install VirtualBox Guest Additions

The "guest additions" are some extra code which can be installed inside the guest OS to improve keyboard and mouse integration, and enable things like copy-paste and easy file transfer between host and guest.

You may need to repeat this every time you install an updated kernel from Ubuntu.

Once this is done, you should find that mousing over the window works without having to capture and release the mouse any more.

Note: copy-paste between guest and host only works with a desktop GUI.

4.2 Install another VM

Create another VM and install from a different ISO image. The instructor may be able to provide you with some other ISO images e.g. Ubuntu Desktop, Antix, Debian, FreeBSD, pfSense, Asterisk Now, or some other operating system. (Antix runs in only 128MB of RAM, or even 64MB if you use the CLI installer)

This is an excellent way to get to learn other operating systems.

4.3 Add a desktop to your server

Your installed Ubuntu Server VM can have a desktop added. There are many to choose from, but LXDE is a compact and lightweight one. All you need to do is:

$ sudo apt-get install xorg lxde
$ sudo service lxdm start

This should switch to a graphical interface where you can login again. You can still get to the text console with Ctrl-Alt-F1, and return to the graphical interface with Ctrl-Alt-F7.

Inside your VM you probably want to disable the screensaver (Start > Preferences > Screensaver) because the default screensavers are very CPU intensive and will drain your laptop battery!

The virtual console screen may be larger than the window on your desktop, so you may need to scroll down to see the bottom line of the console where the LXDE start button is. Start > Accessories > LXTerminal will give you a terminal window.

4.3.1 Reinstall guest additions

When the graphical interface is present, you can reinstall the guest additions (just open the file manager and double-click on autorun.sh)

Then after you reboot the VM, whenever you resize the window the desktop should auto-resize to fit, avoiding the need to scroll.

Furthermore, the "seamless windows" feature should now be available (View > Switch to seamless mode). This scales the VM to fit your available screen and removes the background, so VM windows sit side-by-side with your regular windows.

4.3.2 Copy-paste

If you want to copy-paste between the VM and your host machine, you need to enable it in VirtualBox by selecting

Devices > Shared Clipboard > Bidirectional

Finally, you may also need to open a terminal and run VBoxClient-all in the guest OS before copy-paste works.

4.4 Getting rid of the proxy

If you continue to use this VM outside the classroom, you will find that the HTTP proxy (apt.ws.nsrc.org) is not available. To disable it you need to edit the file /etc/apt/apt.conf and remove or comment out this line:

Acquire::http::Proxy "http://apt.ws.nsrc.org:3142/";

and then run apt-get update. But don't do this until after the end of the system administration section of the workshop.