Wednesday, April 29, 2009

Automatically mounting drives in Ubuntu

I know there's a number of guides out there that show you how to do this, but I always seem to end up combining a number of them to actually get what I want. What I want is the drive to be mounted once I'm logged in (I don't really care when, so long as it's instantly usable).

Here's how I do it

  1. Use sudo blkid to get info about the drive you want to be mounted.

  2. Make the folder that it's going to be mounted in. I normally put a folder in /media/ which has the same name as the drive. This keeps things simple and won't break any symlinks already in place. You do, however, need to unmount the drive first, and of course to make a new folder in /media you'll need to either be root or use sudo.

    I usually do this with:

    sudo mkdir /media/Data

  3. Edit /etc/fstab (you'll need to be sudo) to add the following lines:

    UUID=$DRIVE-ID $FOLDER $TYPE defaults,umask=000 0 0

    This line specifies where to find the drive where to mount it and how. You need to replace $DRIVE-ID with the UUID number for the drive you got from blkid, replace $FOLDER with the full path to the folder you want the drive to be mounted in and $TYPE with the type of filesystem used on the drive, which you can also get from blkid.

    I usually add a comment line, so I know what's happening, then this becomes:

    # /dev/sda5 - Data
    UUID=4820-8D15 /media/Data vfat defaults,umask=000 0 0

That's it. Now whenever you start Ubuntu your drive will already be mounted. If you want to mount it now without rebooting then you can tell Ubuntu to mount everything in the fstab now by using:

mount -a

Wednesday, April 15, 2009

Opening files via WINE in Ubuntu

As a windows user I enjoyed the power of Notepad2 (a lightweight yet powerful notepad replacement), and while the features of gedit are useful they're not what I'm useful. Indeed a number of what I would regard as essential features are in a secondary plugin set that you have to track down in the repos (gedit-plugins), hence I wanted to use Notepad2 in Ubuntu. Thankfully Notepad2 worked immediately under WINE, removing any troubles that I might have incurred there, though I still needed a way to directly open files into the program, preferably via a simple double click.

I investigated using a custom wine command, with a number of various symbols after the path to Notepad2, searching for the one that would pass the filename in a manner that it could understand, but without much luck. Google, however, had some answers and I found this post.

The solution is to call a small bash script which then generates a link file within WINE which points to the file you want. This works fine except that the program inside WINE doesn't get to see the original filename (this isn't a problem when saving, but is annoying when using programs that display the filename in the title bar and elsewhere). To resole this I made a couple of changes to the script such that the link file uses the name of the original file, rather than a pre-defined static one, these mods are in my reply to that thread.