Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

As far as I understood from the mount man page, by default only root is allowed to mount a filesystem. Filesystems with either the user or the users option can be mounted by any user. The owner and the group options allow only an owner and members of a group of a device file respectively to mount/unmount a filesystem.

Is there a way to permit only an arbitrary group to mount/unmount a filesystem?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

@Iain's answer works for any unix. However, in linux you can also specifically allow a group to mount a device.

  • Make the device owned by the group you want to allow to mount it
  • In /etc/fstab, use the option "group" instead of "user"

This is described in the man page for mount(8) (instead of the one for fstab, confusingly):

 FILESYSTEM INDEPENDENT MOUNT OPTIONS
 [...]
 group  Allow  an ordinary (i.e., non-root) user to mount the filesys-
          tem if one of his groups matches  the  group  of  the  device.
          This option implies the options nosuid and nodev (unless over-
          ridden  by  subsequent  options,  as  in   the   option   line
          group,dev,suid).

Here's an example, using the volume "vg_firefly-testmount". I am the user "jenny" with the group "jenny".

[jenny@firefly ~]$ ls -ld /dev/mapper/vg_firefly-testmount 
lrwxrwxrwx 1 root root 7 Nov 26 10:43 /dev/mapper/vg_firefly-testmount -> ../dm-4
[jenny@firefly ~]$ ls -l /dev/dm-4
brw-rw---- 1 root jenny 253, 4 Nov 26 11:35 /dev/dm-4
[jenny@firefly ~]$ grep testmount /etc/fstab 
/dev/mapper/vg_firefly-testmount /testmount             ext4    group,noauto,rw    1 2
[jenny@firefly ~]$ mount /testmount
[jenny@firefly ~]$ mount | grep testmount
/dev/mapper/vg_firefly-testmount on /testmount type ext4 (rw,nosuid,nodev,user=jenny)
share|improve this answer
    
How can I change a device group? Should I edit udev rules for this purpose? The device is a hard drive partition if it's important. –  vect Nov 26 '13 at 9:34
    
I've added an example. –  Jenny D Nov 26 '13 at 11:01
    
Looks strange for me. The /dev/mapper/vg_firefly-testmount link is owned by the root group but you're able to mount it being logged in as jenny. Does mount follow the symlink and look at the group of the linked device? If so, how have you set the group of /dev/dm-4 to jenny? –  vect Nov 26 '13 at 11:41
1  
Mount follows the symlink, just like most other unix commands do, so it's the owner of the actual device that counts. I changed the group ownership of /dev/dm-4 by using "chgrp", just as I would for any other file or device. –  Jenny D Nov 26 '13 at 14:10
add comment

The usual way to do something like this is to use sudo

  • Create a group and add you privileged users to it.
  • Create a script that does the mount/unmount action
  • Ensure the script is executable but writeable only by root.
  • Edit sudoers to allow the group to execute the script
  • Profit
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.