Installing VirtualBox
Jump to navigation
Jump to search
These instructions show how to install a minimal version of Xubuntu Linux under VirtualBox on a Mac. Instructions for a Windows host would be very similar.
Downloading and installing
- Download VirtualBox from https://www.virtualbox.org/wiki/Downloads. I fetched the file http://download.virtualbox.org/virtualbox/5.1.20/VirtualBox-5.1.20-114629-OSX.dmg (90MB).
- Download an Ubuntu installer from https://help.ubuntu.com/community/Installation/MinimalCD. The 32 bit PC version will do, and it's safest to choose the latest LTS (long term support) version. I fetched the file http://archive.ubuntu.com/ubuntu/dists/xenial/main/installer-i386/current/images/netboot/mini.iso (48MB). We will use a minimal, text-based installer because that gives the option of installing only the parts of Ubuntu we need, omitting office suites, e-mail clients, web browsers and the like.
- Double-click on the VirtualBox installer, (if on a Mac) double click on the parcel icon, and accept all defaults.
- There's no need to install a VirtualBox Extension Pack, but it does no harm if you do so.
Creating a virtual machine
- Run VirtualBox via Launchpad or the Start button. Choose New.
- Type a name for the machine (
Compilers
will do), and choose Linux / Ubuntu 32 bit; click Continue (see screenshot). - Accept 1024MB memory.
- Accept Create a virtual hard disk now.
- Accept VDI.
- Accept Dynamically allocated.
- Accept default location and 10GB.
- Type a name for the machine (
Installing Linux
- Select the new machine and click Start. You will be prompted to choose a CD image to boot from; click the icon at the right and find the image
mini.iso
you downloaded earlier. Click Start.
- You are now in a text-mode installer: stop clicking and start typing! Press Return to accept Install.
- Use the arrow keys to choose English on one screen, United Kingdom on the next.
- Say No to Detect keyboard layout, and choose explicitly; I used English (UK) and English (UK, Macintosh), though this gives £ rather than # for Shift-3. Under Windows, you're likely to want English (UK) and English (UK) again.
- Choose a name for your machine if you like, though
ubuntu
will do. - Accept the defaults for the mirror of the Ubuntu archive. No proxy should be needed.
- Type your full name, edit your username if you like, choose a password.
- No to Encrypt your home directory. Accept Europe/London timezone.
- Partition using 'Guided – use entire disk'. Accept defaults. You have to select Yes explicitly to write the new partition table, but it's quite safe: you are operating on a virtual disk held in a file, not directly on the hard disk of your Mac.
- Wait while the basic parts of Linux are downloaded and installed. There are several progress bars that slowly climb to 100%, only for another task to start back at 0%; I hate that.
- Choose No automatic updates and wait some more.
- At the Software selection screen, leave 'standard system utilities' selected and add 'Xubuntu minimal installation' (see screenshot). You could use 'Lubuntu minimal installation' instead, or neither for a text-mode installation. Choose Continue and wait some more.
- Say Yes to 'Install the GRUB boot loader to the master boot record'. (It's the MBR of the virtual disk we're talking about, rather than the MBR of your Mac hard disk – not that it has one.)
- Say Yes to 'System clock set to UTC'.
- When prompted, use the Devices menu and Optical Drives / Remove disk from virtual drive. You will need to use Force Eject. Then allow Linux to reboot.
Settling in
- When Linux comes up, type the password you chose earlier.
- Click on Mouse Whiskers and Terminal Emulator to get a shell prompt.
- Install VirtualBox guest additions. This isn't essential but supports cut and paste between host and guest, and makes the guest desktop resize automatically to fit the host window. Use the command
sudo apt-get install virtualbox-guest-dkms
- Then set up the software we need.
- Type
sudo apt-get install mercurial ocaml-nox
- Type
sudo apt-get install qemu-user gcc-arm-linux-gnueabihf
(Note that tab completion works).
- Type
- Now download and build the lab software.
hg clone http://spivey.oriel.ox.ac.uk/hg/compilers
(cd compilers/lib; make)
(cd compilers/keiko; make)
cd compilers/lab4
make
make test1-pprolog
(see screenshot).
- Install other software you need to work on the labs. For example, a text editor:
sudo apt-get install gedit
. - You can now unmount the VirtualBox disk image and throw it and
mini.iso
in the Trash.
Refinements
- (On the Mac) add a hacked keyboard layout that makes Shift-3 map to #. [Actually, it's already possible to type a # by using RightAlt-3 in Terminal, in Gedit and in Emacs.]
- Change terminal to be black-on-white if that's what you like, or green-on-black if you're 1337. I'm more 4711 myself.
- Reduce the size of the emacs font by doing Options / Set default font followed by Options / Save options. Same for Gedit. (On Xubuntu, it's easier to change these individually than to poke about trying to change the system default.)
Access to the lab machines
You can access the lab machines using SSH from the Linux guest and avoid the messiness of PuTTY on Windows.
- To do this from outside the Oxford domain, it works to connect to VPN in the host (Windows or MacOS), then SSH from the guest. Installing VPN on the guest doesn't work so well, because DNS is no longer available on the guest. This can be fixed, but it's simpler to avoid the problem.
- You can use
ssh-keygen
in the guest to create a login key, followed byssh-copy-id ecs.ox.ac.uk
to install it; then you can access the lab machines without typing a password each time. There's no need to use a passphrase for the key if you don't want to.
$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/mike/.ssh/id_rsa): <enter> Enter passphrase (empty for no passphrase): <enter> Enter same passphrase again: <enter> Your identification has been saved in /home/mike/.ssh/id_rsa. Your public key has been saved in /home/mike/.ssh/id_rsa.pub. $ ssh-copy-id mike@ecs.ox.ac.uk The authenticity of host 'ecs.ox.ac.uk (129.67.150.241)' can't be established. ECDSA key fingerprint is SHA256:RfV6BisTTiQLLxpyxDkuteX0llmVpECefUtUlFOoUpA. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys mike@ecs.ox.ac.uk's password: <password> Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'mike@ecs.ox.ac.uk'" and check to make sure that only the key(s) you wanted were added
- Use
scp ecs.ox.ac.uk:/users/mike/pi/guest-rsa .
to fetch the SSH key needed for access to Mike's Pi server.
Copying files in and out
Create a folder in the host to share, or share your desktop.
- In VirtualBox, use Settings/Shared Folders. Check automount. Save and boot the guest.
- In the guest, add yourself to the
vboxsf
group withaddgroup <name> vboxsf
. Log out and in again. - You will find the shared folder under
/media/sf_<folder>
.
Some alternatives to shared folders:
- For small amounts of text, after installing the guest additions, use cut and paste between host and guest.
- Use a USB key, which can be mounted on the guest by using the USB button at the bottom of the guest window. You may need to install the VB extension pack and enable USB 2.0 or 3.0 to do this.
- Use
scp
to and from a server (such as the lab machines).