LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   mount fstab option group (https://www.linuxquestions.org/questions/linux-newbie-8/mount-fstab-option-group-808659/)

Aigarzs 05-18-2010 01:34 PM

mount fstab option group
 
Good day!

I am trying to set up my usb device to be available to mount and umount only for me, not for other users. Using Slackware 12.2

Entry in fstab is as follows:
Code:

/dev/disk/by-label/USB          /media/usb        vfat auto,group,user,noexec,gid=usb,umask=007  0 0
device information:
Code:

lrwxrwxrwx 1 root root 1 2010-05-18 20:57 /dev/disk/by-label/USB -> ../../sdd1

brw-rw---- 1 root plugdev 8, 49 2010-05-18 20:57 /dev/sdd1

From man mount I have understood that according to my settings only users in group plugdev can mount device, and when mounted it should become owned by user who mounted it and group usb.

Question is: why every user on my system can mount usb device? And what is wrong in my understanding of fstab option group?

Tinkster 05-18-2010 01:37 PM

If you're using KDE chances are HAL is helping them ... you could
play with the udev-rules for the device(s).

Aigarzs 05-22-2010 11:29 AM

Thank you Tinkster.

It is exactly as you said. Playing some evenings with udev I have got what I wanted. Posting this reply just in case it could help someone.

Solution for Slackware 12.2.

USB plug/unplug event is forwarded to udev. Udev does it's stuff and then forwards to hal. If udev didnot solve mounting, hal does that. Noone acts against fstab settings. But hal does its own magic if no fstab entry for device. I solved all usb drives mounting within udev and fstab.

Good udev howto:
http://reactivated.net/writing_udev_rules.html

udev rules location on Slackware:
custom user rules: /etc/udev/rules.d
distribution rules: /lib/udev/rules.d

Udev useful commands:
Code:

#getting udev variables about /dev/sdc1
udevadm info -a -p $(udevadm info -q path -n /dev/sdc1)

#watching udev events occured
udevadm monitor --environment

#testing udev rules on /dev/sdc1
udevadm test $(udevadm info -q path -n /dev/sdc1)

#And here comes my two rules
#I have set them number 78
#After 60 and before system rule 79, because I need fstab info import after device is added.
Code:

#Here my custom script provides symlink name
#I need multiple fstab entries,
#depending on how many usb devices are added and depending on device filesystem

ACTION=="add", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk|partition", ENV{ID_BUS}=="usb", ENV{ID_FS_USAGE}=="filesystem", PROGRAM="/get/symlinkname/from/kernelname/and/fstype %k $env{ID_FS_TYPE}", SYMLINK+="%c", GROUP="usb", MODE="0770"

#Here custom script clears unused mounting points
ACTION=="remove", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk|partition", ENV{ID_BUS}=="usb", ENV{FSTAB_DIR}=="/media/*", RUN+="/delete/mounting/point $env{FSTAB_DIR}"


As result now group "usb" can mount/unmount usb drives instead of default group "plugdev". Also devices are mounted to places I want according to fstab. No conflicts with hal, both KDE and Gnome work fine.

Tinkster 05-22-2010 03:54 PM

Awesome - thanks for posting your solution back in such detail! I'm sure other members
or visitors will find this helpful.


Cheers,
Tink


All times are GMT -5. The time now is 07:51 AM.