What are the default mount settings for mount / fstab?
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 ?
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
, sets noexec,nosuid,nodev
, thus disabling your exec
(and also making your nosuid,nodev
redundant).
The result, as expected, is rw,noexec,nosuid,nodev
.
And no, users
was not ignored, it just doesn't usually show in mount
listing output. But any user can unmount it and mount it back again. Try it!
rodrigo@desktop ~ $ mount /dev/sda6 # ordinary user
rodrigo@desktop ~ $ mount | grep /dev/sda6
/dev/sda6 on /mnt/mint10 type ext4 (rw,noexec,nosuid,nodev)
rodrigo@desktop ~ $ /mnt/mint10/bin/echo it works # noexec will deny this
bash: /mnt/mint10/bin/echo: Permission denied
mount
will only show something related to user if user
(not users
) is used, and an ordinary, non-root user mounts it, like this:
rodrigo@desktop ~ $ mount /dev/sda6 # ordinary user
rodrigo@desktop ~ $ mount | grep /dev/sda6 # it will list current "owner"
/dev/sda6 on /mnt/mint10 type ext4 (rw,noexec,nosuid,nodev,user=rodrigo)
rodrigo@desktop ~ $ umount /dev/sda6
rodrigo@desktop ~ $ sudo mount /dev/sda6
rodrigo@desktop ~ $ mount | grep /dev/sda6 # since owner=root, it won't show
/dev/sda6 on /mnt/mint10 type ext4 (rw,noexec,nosuid,nodev)
rodrigo@desktop ~ $ umount /dev/sda6 # only mounter can unmount
umount: only root can unmount LABEL=MINT10 from /mnt/mint10
Also notice that, when using user
without noauto
, 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:
LABEL=NewHome20G /media/NewHome20G ext3 users,exec 0 2
Notice how exec
is after users
. And also rw,nosuid,nodev
is not necessary. rw
is already a default, and the others are automatically turned on by users
And the result is:
rodrigo@desktop ~ $ mount /dev/sda6 # user mount
rodrigo@desktop ~ $ mount | grep /dev/sda6
/dev/sda6 on /mnt/mint10 type ext4 (rw,nosuid,nodev)
rodrigo@desktop ~ $ /mnt/mint10/bin/echo it works # exec works
it works
rodrigo@desktop ~ $ sudo umount /dev/sda6 # root unmount
rodrigo@desktop ~ $ sudo mount /dev/sda6 # root mount
rodrigo@desktop ~ $ mount | grep /dev/sda6
/dev/sda6 on /mnt/mint10 type ext4 (rw,nosuid,nodev)
rodrigo@desktop ~ $ umount /dev/sda6 # user unmount
rodrigo@desktop ~ $
Meaning any user, root or non-root, can mount and unmount it, regardless of who previously mounted or unmounted it. And executables works too :)