Posts tagged ‘usb’

LUKS on GNOME

Erik, it just works for me. I have LUKS on a partition on a USB stick. When inserted I get a dialogue box asking for the LUKS password. I had to configure hal a little to give the desktop icon a good name:

<device>
  <match key="volume.uuid" string="d23647f8-22be-4a8c-86f8-8f59975e9e61">
    <merge key="volume.label" type="string">StickSecret</merge>
  </match>
</device>

USB storage in Breezy

I wrote a post on using udev together with Gnome Volume Manager (GVM). My recent upgrade to Ubuntu Breezy revealed that my hack was just that, a hack, and a bad hack at that. It doesn’t work in Breezy!

It turns out there’s a right way of doing this—use HAL! As so often I could have saved some time by simply reading the comments in the configuration files in /etc. (BTW, this is exactly the reason why I love Debian/Ubuntu. The configuration files are their own documentation. Brilliant, simply brilliant.) Anyway, playing around a little with HAL’s fdi files wasn’t a bad thing I guess. In the end I retired my udev setup from my earlier post and put the following lines in /etc/hal/fdi/policy/local.fdi:

<device>
  <match key="volume.uuid" string="60CA-2822">
    <merge key="storage.automount_enabled_hint"
      type="bool">false</merge>
  </match>
</device>

This hint is honoured by GVM and the device isn’t mounted.

RedHat published quite a useful introduction to hal. The hal specification is also a good place to find information.

udev for USB sticks

I am not too fond of Gnome’s volume manager (GVM). I still use it, but for one of my sticks it doesn’t quite suffice, at least not for my current use of that stick. GVM doesn’t seem to handle USB sticks with multiple partitions that well (it mounts all partitions as well as the basic device), it doesn’t mount them with nice names (for FAT partitions it seems to take the volume name, nice, but ext2 doesn’t have a volume name). I’ve put two partitions on my USB stick, one FAT and one ext2. The first one I use for moving files between work and home, since I’m forced to use Windows at work :( The second one is where I put my important things, GNUPG keys, lists of passwords for different places, etc. I simply don’t trust FAT that much so the option of having one big FAT partition with a file mount on a loop device didn’t give me the same warm and fuzzy feeling as two separate partitions.

Just popping the stick in will most likely cause GVM to mount it for you. Unmount it using the right mouse button then throw up a terminal. This is what I did to find the required information on my USB stick:

$ udevinfo -q path -n /dev/sda
/block/sda
$ udevinfo -a -p /sys/block/sda | less

Look for a an entry the looks like this SYSFS{serial}="070B000514B09F0". Now you know enough to set up your udev rule. I don’t like modifying system files so I created a new one /etc/udev/rules.d/local.rules and put the following line in it:

BUS="usb", SYSFS{serial}="070B000514B09F0", KERNEL="sd*", \
  NAME="%k", SYMLINK="usbstick_priv%n"

This means that when my USB stick is inserted a few symlinks will be created, one for the device (usbstick_priv to sdX) and one for each partition (usbstick_priv1 to sdX1, etc). Pretty nice, I think, since it doesn’t matter what X is. Then I use pmount to mount the partitions using the link names:

pmount /dev/usbstick_priv1 mystick_1
pmount /dev/usbstick_priv2 mystick_2

More information can be found in the document titled Writing udev rules.