MP3 USB devices and Fedora

I just treated myself to a little MP3 player from Tesco. They are down to £9.97 in-store (still £19.99 online). It is a small USB stick, 256Mb with a blue backlit display. Apart from anything else I could do with the extra storage for transferring files, and with the onboard MP3/WMA capabilities this is great… I'm one of the unwashed masses lacking an iPod.

I thought it would be a good idea to record how I got it recognised on my Fedora Core 4 system, since it took me a while…

Using information from the Debian Administration pages I learned quite a bit about the way udev is supposed to work. I think I've got it, now.

I plugged the stick into the nearest USB port and it was recognised by the kernel:

Dec 23 18:26:44 castor kernel: USB Mass Storage support registered.
Dec 23 18:26:49 castor kernel: Vendor: SigmaTel Model: MSCN Rev: 0100
Dec 23 18:26:49 castor kernel: Type: Direct-Access ANSI SCSI revision: 04
Dec 23 18:26:49 castor kernel: SCSI device sdd: 493568 512-byte hdwr sectors (253 MB)
Dec 23 18:26:49 castor kernel: sdd: Write Protect is off
Dec 23 18:26:49 castor kernel: sdd: assuming drive cache: write through
Dec 23 18:26:49 castor kernel: SCSI device sdd: 493568 512-byte hdwr sectors (253 MB)
Dec 23 18:26:49 castor kernel: sdd: Write Protect is off
Dec 23 18:26:49 castor kernel: sdd: assuming drive cache: write through
Dec 23 18:26:49 castor kernel: sdd: sdd1
Dec 23 18:26:49 castor kernel: Attached scsi removable disk sdd at scsi3, channel 0, id 0, lun 0

The next step (actually not directly the next step for me – I spent ages fiddling around with hal before realising this is handled by udev… but if you're following this, it should be your next step) was to create a file called /etc/udev/rules.d/local.rules containing this line:

BUS="scsi", SYSFS{model}="MSCN ", KERNEL="sd?1", NAME="%k", SYMLINK="mp3player"

The information in quotes for SYSFS{model} was taken from a file called model in the /sys filesystem:

[andyp@castor ~]$ find /sys -name model
/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.2/1-6.2:1.0/host3/target3:0:0/3:0:0:0/model
/sys/devices/pci0000:00/0000:00:0f.0/host1/target1:0:0/1:0:0:0/model
/sys/devices/pci0000:00/0000:00:0f.0/host0/target0:0:0/0:0:0:0/model
/sys/devices/platform/host2/target2:0:6/2:0:6:0/model

(the first one of those files – I opened it using vi as I needed to check exactly how many trailing spaces there were)

What this achieves is that when this model of device is plugged in, udev creates a symbolic link /dev/mp3player pointing at whichever /dev/sdX device the kernel has created it at.

Then I edited /etc/fstab:

/dev/mp3player /media/mp3player auto auto,user 0 0

I created a mount point called /media/mp3player.
I restarted udev and unplugged the device. The next time I plugged it in, /dev/mp3player magically appeared. In GNOME I could mount the device. I then assigned a custom icon to the device (an iPod – I can dream!) and away I went.

Technorati tags:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s