I'm trying to take advantage of the "group" option for fstab entries and not having any success. From the mount
man page:
Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, anybody can mount the corresponding system. ... If any user should be able to unmount, then use users instead of user in the fstab line. The owner option is similar to the user option, with the restriction that the user must be the owner of the special file. This may be useful e.g. for /dev/fd if a login script makes the console user owner of this device. The group option is similar, with the restriction that the user must be member of the group of the special file.
I'm testing with a loopback mount using a 1GB file /blergh with an ext4 filesystem on it. That file is owned by root:disk with permissions 664. I have a mount point /media/blergh owned by root:disk with permissions 775. I have an fstab entry like so:
/blergh /media/blergh ext4 loop,rw,noauto,group 0 2
Running mount /media/blergh
as root
works fine. Running it as myuser
gives the error: mount: only root can mount /blergh on /media/blergh
. The output of /usr/bin/groups
as myuser
is myuser disk
so the group membership is there. If I change group
to user
in the options, myuser
can mount the filesystem.
What am I doing wrong? Why isn't the group
option working?
(Note: for reasons I don't want to get into here, I do not want to solve the problem of enabling myuser
to mount this filesystem by using sudo
.)
Edit 20-MAY-2013:
Additional testing with a real block device suggests the problem lies with loop
rather than group
. I created a new 1GB EBS volume attached as /dev/sdg, owned by root:disk, permissions 664. I created this fstab entry for it:
/dev/sdg /media/sdg ext4 rw,noauto,group 0 0
Same as before, just no loop
since it does not apply here. I created a mount point for this filesystem at /media/blerg, owned by root:disk, permissions 775. As before myuser
is a member of the disk
group. Using this test setup mount /media/sdg
as myuser
works fine, as does umount /media/sdg
.
groups myuser
it will display the groupsmyuser
is a member of from the groups file. If you rungroups
(no argument) asmyuser
it will show the current groups the process has. If these differ, you will need to log out and in again to get the new groups applied (or usenewgrp(1)
)groups
command confirms it.