Thursday, August 11, 2011

Trying Ubuntu Linux (1)

I thought I would play around with Linux a bit, trying to improve my Unix skills. I'm running it in a second partition on my Macbook that has OS X Lion installed (post here) and runs a Virtual Box VM.

I first heard about and tried Oracle's Virtual Box in connection with QIIME (post here).

I grabbed a VirtualBox version 4.1 binary installer for Mac OS X here.

Then I downloaded Ubuntu Linux 11.04 (now why is it called Natty Narwhal?) from here. There is another download page here but I think it has the same choices.

I ended up trying both Desktop "CD"s, because I was a little confused about the version I needed. There appears to be only 32-bit for i386 (ubuntu-11.04-desktop-i386.iso) but 64-bit for AMD (ubuntu-11.04-desktop-amd64.iso). However, the chip running the host OS is not relevant. The QIIME Linux is labeled AMD64 and is 64-bit and can run on my 64-bit machines under a VM. I suppose it would matter if I wanted to run Linux directly in the partition instead of in Virtual Box.

I have to confess, I've installed several different Linux versions (and then removed them) and the one described here a number of times, because I ran into problems with the install that I couldn't figure out how to back out of. But experimentation is relatively cheap, since it's just a VM. I don't have any worries about leftover crap on my disk. If worst comes to worst I can just erase the whole partition. Although it takes patience for the install steps.

Stock 64-bit Ubuntu Linux

So, I ran the Virtual Box installer, set the Name as Ubuntu, Operating System as Linux and the Version as Ubuntu 64. Then I set up the VM with all standard options (except 1 GB for RAM). Just click on through.

To actually install Linux using a .iso file, use the "First Run Wizard" by double-clicking the new machine in the list. For Select Installation Media: I navigated to the saved file. On one try I somehow got past the Wizard without properly installing and had to delete and re-configure the VM.

It takes quite a while to boot the first time, copying all the files over to the VM, I guess. Choose Erase disk and install Ubuntu (the disk size should be only the size of the VM disk). There are a bunch of dialogs to go through. After the install and reboot we get a message that Unity won't run on our hardware and so we're going to get Classic. Oh well.


Now, there are two things that seem really important to have but are not present in this stock install:

• a Shared Folder for file sharing between host and guest OS
• a Clipboard for copy/paste between host and guest OS

To have these features you must install what are called the "Guest Additions," which are additions to the Linux kernel. Some instructions are on this page:

After you have installed the Linux Guest system, there are a few additional packages needed for the Guest Additions. These packages enables you to create kernel modules. For Debian and Debian based distro's like Ubuntu, you need the following packages:

Find the Terminal (why not just drag it to the menu bar) and do:

sudo apt-get install dkms build-essential linux-headers-generic

You'll have to type in the command, since copy/paste doesn't work yet :)
When it's done:

Reboot to make the changes effective..

Next, "mount" the Guest Additions "iso": in the VB menu (in OS X) under Devices, choose Install Guest Additions. It shows up as a CD on the Desktop. Then from the dialog choose the default that automatically runs the shell script. Or hit Open AutoRun Prompt > OK and then in Terminal do:


After it's done, reboot again..

At this point, copy/paste between host/guest should work. You'll have to click twice, once to switch focus to the VM and once to switch focus again to whatever application is receiving the paste.

There are two different key combos for Linux and neither is CMD. Not sure if this is standard Linux or it is just since the left CMD key is a special key for the VM. To copy and paste within Terminal on Linux use CTL-SHIFT-x and CTL-SHIFT-v rather than CMD (for Text Edit just use CTL-x and CTL-v).

Now we can try to get shared folders. In the Virtual Box window, from the Devices menu choose Shared Folders. Add a folder (navigate the host OS to the desired path). Also, make a folder under Linux that we'll use to share with, say /home/telliott/Desktop/share

In the dialog, choose Automount (and Make Permanent, see below). Even after the specification of a shared folder, you still have to mount it within Linux. The Qiime guys do:

sudo mount -a

Unfortunately, it doesn't seem to work for me. (Not in the Qiime install either). So then I tried this:

sudo mount -t vboxsf -o uid=1000,gid=1000 shared ~/Desktop/share

The first argument after vboxsf above is the name of the folder on the host OS (as defined by us in the Devices menu above). The second argument is the name of the sharepoint --- the path to a folder on the Guest.

It didn't work at first, because it turned out, I had failed to check Automount above. And, if you want to make a change to the Shared Folder setting, it seems that you have to reboot to be able to actually do it, otherwise there's a message about the resource being in use.

Also, I never did figure out how to change Make Permanent. Any change or attempt to delete in the Shared Folders dialog (even after a reboot) gives an error message: VERR_PERMISSION_DENIED. There's a note in the link about putting the mount command in


but I don't see how that's going to work since it needs to run as root? Luckily, the VM allows me to suspend Linux in its current state. And now, thinking that I need to re-run that command every time upon booting, I try it and get:

sudo mount -t vboxsf -o uid=1000,gid=1000 shared ~/Desktop/share
/sbin/mount.vboxsf: mounting failed with the error: Invalid argument

After re-boot, the same mount fails! I am starting to get angry with this thing.

I gave up and set up Dropbox access from within the VM. It works great.

Now, to build some software.