Topic: Computers Removable devices


4:29pm, Tuesday 3 January 2006

Task: configure a Linux box so that when my MP3 player is plugged in, it consistently appears as /dev/muvo - rather than /dev/sda1 or /dev/sdc1 or /dev/xyz1 depending on whether the digital camera, USB drive, or whatever also happen to be plugged in at the time. For bonus points, automatically mount it on /muvo.

Solution 1: hotplug. Er, ick. Fiendishly complicated with no obvious "howto" guide. This is what I ended up with:

  1. create /etc/hotplug/usb/fred.usermap containing
    fred 0x0003 0x041e 0x412b 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000
    (no, I don't know what most of those are either, but the third and fourth fields are the USB vendor and product ID's)
  2. write a grotty shell script - /etc/hotplug/usb/fred - which greps the last bit of /var/log/syslog for a SCSI disk appearing, and based on the USB ID it's been passed, mounts the device somewhere appropriate; and also registers a "remover" for when the device disappears.
  3. restart hotplug
It more or less works, and can be extended to handle different devices by hacking the "fred" script. But it falls over if a device is inserted, removed and reinserted while another is already present. The second insertion seems to go unnoticed. Not good enough.

Solution 2: udev. Er, also fiendishly complicated, but there's a comprehensive guide to writing udev rules with lots of examples which made it easy to find the answer. Create /etc/udev/rules.d/my.rules containing

BUS=="scsi", SYSFS{vendor}=="CREATIVE", SYSFS{model}=="MuVo N200*", KERNEL=="sd?1", NAME="%k", SYMLINK="muvo"
and restart udev. Much nicer. It doesn't automatically mount the disk, but the automounter can do that: in /etc/auto.misc, put
muvo         -fstype=vfat,sync       :/dev/muvo
and "cd /misc/muvo" works the magic.

back to main


Powered by Personal Weblog.

February 2018
Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      
Jan   Mar




Dave Holland <>
$Id: index.php,v 1.75 2010-07-09 22:15:04 dave Exp $