[Techtalk] udev, how do I loathe thee...help please!
akkana at shallowsky.com
Mon Nov 8 05:08:51 UTC 2010
Carla Schroder writes:
> Problem: I have an 8GB SD card formatted ext2, and I use a nice USB card
> reader. I want it to mount with read/write permissions for me, chown
> carla:carla. Because, you know, I might actually want to use it. Ideally I
> would like it to mount in my homedir rather than /media. (This is on an
> Ubuntu Lipless Lynx system or whatever the eff it is.)
I don't think you set those permissions with udev. At least, I handle
that with fstab. For cameras, USB sticks and any other "plug into USB
occasionally, it's not always there" USB storage devices that will
have vfat filesystems on them, I use this fstab line:
/dev/sdf1 /pix vfat user,noauto,exec,fmask=111,shortname=lower 0 0
/pix is where I'm going to mount it, so you could make that
/home/carla/mystuff or anything you want. user,noauto means don't
try to mount it at boot time, but let me or any user type "mount /pix"
as myself without needing to su or sudo. (It's possible I might need
to be in some group for this, perhaps plugdev, though I don't think so.)
fmask=111 keeps all the jpg files and mp3 files from being executable
since silly vfat doesn't have that concept. shortname=lower keeps
the filenames from being ALLCAPS.JPG.
If you're using a proper Linux filesystem instead of vfat,
then you don't need all the extra stuff, just something like
user,noauto,defaults. And once it's mounted the files will have
whatever permission they have on the usb device's filesystem.
Those udev rules I talk about on my blog page have to do with my
multi-flash-card reader that's always plugged in, but which doesn't
have a card in it 'til I insert one, so udev normally doesn't
create the devices for the partitions (like /dev/sdc1) unless you
run some silly daemon like hal. Once I make the udev rule so I've
renamed the SD card reader to /dev/card-sd and told it to create
partitions like /dev/card-sd1, then I use an fstab line just like
the other one:
/dev/card-sd1 /sdcard vfat user,noauto,exec,fmask=111,shortname=lower 0 0
Note that gnome, hal, udisks and a bevy of other daemons and services
are supposed to handle all this for you and automount the card. So
this is all for curmudgeons like me who don't want all that stuff
running and don't mind typing "mount /pix" now and then.
More information about the Techtalk