What are the default mounting options for a non root partition ?
The man entry for mount says …
defaults - use default options: rw, suid, dev, exec, auto, nouser, and async.
… so that might be what we expect to see. But, unless I'm missing something, that's not what happens.
I have an ext3 partition labelled "NewHome20G" which is seen as /dev/sdc6 by the system. This we can see from …
root@john-pc1204:~# blkid | grep NewHome20G
/dev/sdc6: LABEL="NewHome20G" UUID="d024bad5-906c-46c0-b7d4-812daf2c9628" TYPE="ext3"
I have an entry in fstab as follows …
root@john-pc1204:~# cat /etc/fstab | grep NewHome
LABEL=NewHome20G /media/NewHome20G ext3 rw,nosuid,nodev,exec,users 0 2
Note the option settings that are specified in that fstab line.
Now I look at how the partition is actually mounted after boot up …
root@john-pc1204:~# mount -l | grep sdc6
/dev/sdc6 on /media/NewHome20G type ext3 (rw,noexec,nosuid,nodev) [NewHome20G]
… so, when the filesystem gets mounted the exec & users options I specified seem to have been ignored.
Just to be sure, I unmount sdc6, remount it and look at the mount options again …
root@john-pc1204:~# umount /dev/sdc6
root@john-pc1204:~# mount /dev/sdc6
root@john-pc1204:~# mount -l | grep sdc6
/dev/sdc6 on /media/NewHome20G type ext3 (rw,noexec,nosuid,nodev) [NewHome20G]
…. same result
Now I unmount the partition again, remount it specifying the exec option and look at the result …
root@john-pc1204:~# umount /dev/sdc6
root@john-pc1204:~# mount /dev/sdc6 -o exec
root@john-pc1204:~# mount -l | grep sdc6
/dev/sdc6 on /media/NewHome20G type ext3 (rw,nosuid,nodev) [NewHome20G]
… and here the exec option has finally taken effect and the noexec setting has vanished.
Just for interest, I re-mount the partition with the defaults option
root@john-pc1204:~# umount /dev/sdc6
root@john-pc1204:~# mount /dev/sdc6 -o defaults
root@john-pc1204:~# mount -l | grep sdc6
/dev/sdc6 on /media/NewHome20G type ext3 (rw,noexec,nosuid,nodev) [NewHome20G]
The noexec is back, so it looks very like rw,noexec,nosuid,nodev are the default options which is NOT what man says.
Why does this matter ?
I have a folder full of useful scripts stored on a data disk. Because that disk is mounted noexec
those scripts won't run, even though they have all been set with chmod 777. I can work round this in several ways but it's disappointing that the man entry seems to be wrong.
Have I missed something obvious here or have the default options in Ubuntu changed from what they were a few versions ago ?
Best Answer
The manual is correct. Your issue is that perhaps you didn't account for 3 important details:
users
(anduser
) implies the optionsnoexec
,nosuid
, andnodev
Unless overridden by subsequent options
Options order matters ;)
So when you use
rw,nosuid,nodev,exec,users
in your fstab, the last option,users
, setsnoexec,nosuid,nodev
, thus disabling yourexec
(and also making yournosuid,nodev
redundant).The result, as expected, is
rw,noexec,nosuid,nodev
.And no,
users
was not ignored, it just doesn't usually show inmount
listing output. But any user can unmount it and mount it back again. Try it!mount
will only show something related to user ifuser
(notusers
) is used, and an ordinary, non-root user mounts it, like this:Also notice that, when using
user
withoutnoauto
, the partition will be automounted (by root) on boot. So until root unmounts it, no one will be able to unmount or (re-)mount.That said, I guess you already figured out your solution: simply change the order of your options and everything will work fine:
Notice how
exec
is afterusers
. And alsorw,nosuid,nodev
is not necessary.rw
is already a default, and the others are automatically turned on byusers
And the result is:
Meaning any user, root or non-root, can mount and unmount it, regardless of who previously mounted or unmounted it. And executables works too :)