usb drive annoyance with kde and udev
As it turns out, there’s really very little to blog about regarding my Slackware 12.1 installation. Almost everything Just Works.
Update: I gave up on the approach below and solved the problem by modifying the kdeeject script per comment 13 in this Gentoo bug report. This seems a lot better than screwing with the device’s permissions.
The only actual problem I have, and it’s really just an annoyance, is with KDE’s option to “safely remove device” for USB drives. That option uses eject instead of just umount. That’s fine, as eject works on my USB drives as long as the user has enough permission.
The problem arises because of default udev rules that make the owner of the device root:disk, and the user isn’t in the disk group. eject calls umount, so the device is unmounted, and no harm is done. But eject exits with error code 1, so KDE throws up an error window (along with its lovely breaking glass sound).
Two solutions mentioned on the intertron are to patch the KDE component which handles “safely remove” or to modify a script KDE uses. The third solution, which I would like to use, is just to write a new udev rule to make sure the device is owned by root:plugdev (and of course the user should be in the plugdev group). I’ve done this for just the WD drive which has the problem, but a rule can be written to handle all removable storage. The rule has to be processed after the default udev rules handling block devices.
That’s a pretty good rundown of my understanding of the problem, but something is lacking in my understanding, because that solution doesn’t work under Slackware. It does work under Gentoo, where I had the same problem.
I’m in the plugdev group, and here are the drive’s permissions:
$ ls -l /dev/bigpassport brw-rw---- 1 root plugdev 8, 17 2008-05-13 17:50 /dev/bigpassport
I still think it’s a permissions problem, since eject does work when run as root. Here’s the eject output, with the drive mounted first, for user:
$ eject -v bigpassport; echo "exit code $?" eject: device name is `bigpassport' eject: expanded name is `/dev/bigpassport' eject: `/dev/bigpassport' is mounted at `/media/bigpassport' eject: unmounting device `/dev/bigpassport' from `/media/bigpassport' eject: `/dev/bigpassport' is not a multipartition device eject: trying to eject `/dev/bigpassport' using CD-ROM eject command eject: CD-ROM eject command failed eject: trying to eject `/dev/bigpassport' using SCSI commands eject: SCSI eject failed eject: trying to eject `/dev/bigpassport' using floppy eject command eject: floppy eject command failed eject: trying to eject `/dev/bigpassport' using tape offline command eject: tape offline command failed eject: unable to eject, last error: Invalid argument exit code 1
And for root:
# eject -v bigpassport; echo exit code "$?" eject: device name is `bigpassport' eject: expanded name is `/dev/bigpassport' eject: `/dev/bigpassport' is mounted at `/media/bigpassport' eject: unmounting device `/dev/bigpassport' from `/media/bigpassport' eject: `/dev/bigpassport' is not a multipartition device eject: trying to eject `/dev/bigpassport' using CD-ROM eject command eject: CD-ROM eject command failed eject: trying to eject `/dev/bigpassport' using SCSI commands eject: SCSI eject succeeded exit code 0
If you solve this problem, please blog about it. I can’t get my ipod to umount, with exactly the same errors as you talk about. Since it is my wife’s machine, her ipod, and she has no idea how to log in as root and run eject, I have to solve this or get nagged every time she plugs in her ipod.
I got it fixed by modifying the kdeeject script. I hope the same thing will work for the iPod.