May 05 2008

Mounting Removable Drives At Boot In eeeXubuntu

Tag: linuxSymon Rottem @ 10:53 pm

Now that was more interesting.

Today I managed to solve the question I asked in my last post, namely how does one set up a removable USB drive to automatically mount at boot. I was trawling around and not getting anywhere when I left you last.

My next course of action was to impose upon a colleague who has more Linux experience than I do and he pointed me to setting up mount commands to execute during start up and, more importantly gave me a quick overview of how the startup process works in Linux. He’s got himself an Eee PC too, so he’s been around the block, but he uses his as it was meant to be used – as a portable unit.

Anyway, based on his advice I found this page which provides an excellent overview of the startup process and scripting in Linux and that page gave me the idea of using the /etc/rc.local file to execute my mount commands.

Before that, however, I decided to clean up my /etc/fstab to use the UUID of the drive to make things a little more reliable. To do that I needed to find out what the UUID actually was…fortunately in the Ubuntu Linux disks can be found under /dev/disk/by-label which shows the label of the disk (useful for identifying a drive for a human being) and /dev/disk/by-uuid (which is better for computers to identify a disk).

By executing…

 ls -la /dev/disk/by-label

…I get the list of disk labels and the corresponding device it’s mounted as for the moment:

total 0
drwxr-xr-x 2 root root 100 2008-05-05 23:13 .
drwxr-xr-x 6 root root 120 2008-05-05 22:58 ..
lrwxrwxrwx 1 root root  10 2008-05-05 22:58 Big\x20Disk -> ../../sdb1
lrwxrwxrwx 1 root root  10 2008-05-05 23:05 Media\x20Disk -> ../../sdd1
lrwxrwxrwx 1 root root  10 2008-05-05 23:13 PORTABLE -> ../../sde1

And then by executing…

ls -la /dev/disk/by-uuid

I can see the UUIDs of the disks and the same corresponding device.

total 0
drwxr-xr-x 2 root root 140 2008-05-05 23:13 .
drwxr-xr-x 6 root root 120 2008-05-05 22:58 ..
lrwxrwxrwx 1 root root  10 2008-05-05 19:31 22dc6988-36c5-4e98-976b-321aa3f04cba -> ../../sda1
lrwxrwxrwx 1 root root  10 2008-05-05 22:58 2C300B22300AF31E -> ../../sdb1
lrwxrwxrwx 1 root root  10 2008-05-05 23:13 584C2EE74C2EBF9C -> ../../sde1
lrwxrwxrwx 1 root root  10 2008-05-05 19:31 d32d39d4-cbac-41ba-b9c5-b08b95ef5286 -> ../../sda5
lrwxrwxrwx 1 root root  10 2008-05-05 23:05 EC00D02C00D0000E -> ../../sdd1

So, since I now know that the disk with the label PORTABLE is corresponds to device sde1 and that sde1 also corresponds to the UUID EC00D02C00D0000E…I think you get the idea.

Now I want to mount each of these drives under a single folder so I can expose that folder as a Windows share to access all of these disks from across the network, so first I’ll create a new folder on my root filesystem – /storage. Next I’ll create a subfolder for each of the disks I want to mount; I’m going to base the names on the labels of the disks:

sudo mkdir /storage
sudo mkdir /storage/big
sudo mkdir /storage/media
sudo mkdir /storage/portable

Next, by adding each of these to the /etc/fstab file I can configure the system with some information about how these filesystems should be accessed and mounted. Executing…

sudo nano /etc/fstab

…opens the fstab file for editing (I’d recommend making a backup first to be safe) and then I can add the new lines for the new mountpoints at the end of the file:

# USB disk mounts
/dev/disk/by-uuid/584C2EE74C2EBF9C /storage/portable ntfs nls=utf8,umask=0222 0 0
/dev/disk/by-uuid/2C300B22300AF31E /storage/big ntfs nls=utf8,umask=0222 0 0
/dev/disk/by-uuid/EC00D02C00D0000E /storage/media ntfs nls=utf8,umask=0222 0 0

Each of these lines is made up of the device path (using the UUID version we determined earlier), followed by the folder to mount it to and some additional information about the filesystem which I won’t go into right now; you can do some research of your own if you need to know!

Once the file has been saved you can test the mounts by executing…

sudo mount -a

…which will mount the filesystems using the fstab file. At this point if I get a directory listing for /storage/portable I can now see the contents of the USB disk! Woohoo!

So, on to the final step – getting the drives to mount during the boot process. I did this using the /etc/rc.local file. In a default Ubuntu installation this file does nothing but it’s a good point for adding some final steps of your own during the boot process.

The file ends with an exit 0, so before that line I added my mount commands to mount each of my drives:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

mount /dev/disk/by-uuid/584C2EE74C2EBF9C /storage/portable
mount /dev/disk/by-uuid/2C300B22300AF31E /storage/big
mount /dev/disk/by-uuid/EC00D02C00D0000E /storage/media
exit 0

After that’s saved, reboot and voila! Auto mounted removable disks!


May 05 2008

eeeXubuntu

Tag: linuxSymon Rottem @ 8:45 am

Well that didn’t take long.

Continuing on my last post about setting up an Eee PC as a server I’ve gone ahead and replaced the existing software on my Eee PC with a fork of Xubuntu called, funnily enough eeeXubuntu that has built in support for all the Eee PC hardware and is optimized for for it’s itty-bitty screen.

Not too hard, I must say. The folks at eeeuser.com have been good enough to set up a wiki with simple instructions for putting the LiveCD image onto a USB key to install (since the Eee PC doesn’t have a CDROM) and the installation was smooth sailing. Everything good, everything easy, no exceptions. In about 30 minutes I had a desktop login, wireless and wired network connectivity, everything.

The next step was to get a LAMP install on the machine. After a little searching around I discovered that there’s a utility provided with the distro called tasksel that provides a simple set of check boxes to set up LAMP, SAMBA, alternate desktops and more. There appears to be a bug with tasksel that causes it to hang when the install gets to 100%, but everything seems to install OK. At least I know Apache is running; I can reach it from the other machines on my network through a browser.

Wow – I’m well underway.

Next step was to get printer sharing working. I plugged in the printer – it was auto-detected. The printer control dialog offered me the option to share the printer…done. Then I added the printer to my Windows notebook using the add printer wizard – things were a little different there; I had to use the internet network printer approach rather than the way I normally would; that took about 10 minutes research.

Hmm. This is all too easy. Am I actually going to learn anything here?

Now to connect my real storage. Since the Eee PC only has 4Gb of onboard storage I’m going to supplement it with removable USB drives and I’m going to expose that using Windows shares. Since I installed SAMBA when running tasksel above I should be able to plug in and share….

Ok. Now I’m learning.

After about 6 hours of persistent stuffing around I’ve managed to get it so that the USB drive will always appear in the same device location and I’ve managed to edit the /etc/fstab file so I can get it mounted to a known location using sudo mount -a and I’ve shared that I’ve shared with SAMBA. Woohoo!

But as with all learning (especially when the curve is steep) there’s a point where you get stuck; I can share the folder, but I can’t get the removable USB disk to re-mount itself on reboot. I can manually mount it by executing sudo mount -a again, but it won’t happen automatically and I don’t want to have to log into a console to get it going again after a reboot.

Since it’s now after midnight I’m going to pack it in for the day, but if anyone’s got any ideas on how to get the drive to mount automatically on boot I’d love to hear them.