Friday, February 3, 2017

Running Ubuntu in VirtualBox on Windows

Introduction
Every time I need to set up another virtual machine it has been so long I can't remember how exactly it was done. It is not complicated but finding a working solution always takes time and makes me quite frustrated. So here is an attempt to save time and energy next time it will happen.

System choices
Don't ask me why but during my career all computers have run Windows (except a brief time on OSX). So you end up with Windows but very often the software you work with can only run on *nix OS:s. Enter virtual machines (VM). Personally I like VirtualBox, so I stick to it. Ubuntu is a nice Linux distro and most computers these days run Windows 10. So there we go!

Installation
  1. Install VirtualBox using the appropriate installer from their download page.
  2. Download a disk image (a .iso file) from Ubuntu.
  3. Create a folder in Windows that will be shared with the VM. It must not have any spaces, eg C:\shared.
  4. Create a new VM in VirtualBox (by clicking New, chosing Linux and Ubuntu and just going with the default values unless you know what you want).
  5. Add the folder created to Settings -> Shared Folders in VirtualBox. Be sure to select the Auto-mount option.
  6. In Settings -> General -> Advanced select the Shared Clipboard as well as Drag'n'Drop to be Bidirectional.
  7. When starting the VM just created, chose the iso file when VirtualBox prompts for a start medium. (The installation of Ubuntu is outside the scope of this post but being in a VM the worst thing that can happen is that the VM crashes.)
  8. Install the VirtualBox Guest Additions by selecting Insert Guest Additions CD image in the Devices menu and then restart the VM.
  9. The shared folder will be mounted at /media/sf_shared but to access it the user has to belong to the vboxsf group, so: sudo usermod -a -G vboxsf username
  10. Restart the VM. (This is weird bit the group change is spooky, try id and id username and go figure...)
  11. I prefer having a link in my home directory for quick access: ln -s /media/sf_shared shared
 On my Asus ZenBook the text in the VM gets awfully small but it is possible to change in the View -> Scale Factor menu option. One last note on encryption too: It makes the VM super slow, so I'd avoid it, it is slow enough as it is.

No comments: