[sf-lug] mounting and permissions

Rick Moen rick at linuxmafia.com
Fri Apr 15 01:02:19 PDT 2022

Quoting Alex Kleider (alexkleider at protonmail.com):

> I'm running Debian 10/xfce
> Only root is authorized to mount.
> When I mount a thumb drive, the owner of the mount point is root:root
> but even root doesn't have authority to  # chown alex:alex ~alex/mnt
> Surely there must be a way that I can mount something and have permission to write to it?
> Can anyone enlighten me?

Here's one way:

Quoting from the "man 8 mount" section for FAT filesystems:

       uid=value and gid=value
              Set the owner and group of all files.  (Default: the uid and gid
              of the current process.)

Of course, you'd prolly wanna automate that, so here's the relevant
excerpt from "man 5 fstab" about the format of /etc/fstab (the
filesystem table, parsed and fed to /bin/mount at boot time):

      The fourth field, (fs_mntops), describes the mount  options associated
       with the filesystem.

       It  is  formatted as a comma separated list of options.  It contains at
       least the type of mount plus any additional options appropriate to  the
       filesystem  type.   For documentation on the available options for non-
       nfs file systems, see mount(8).  For documentation on all nfs-specific
       options have a look at nfs(5).  Common for all types of file system are
       the options ``noauto'' (do not mount when "mount -a" is given, e.g., at
       boot  time),  ``user''  (allow  a  user to mount), and ``owner'' (allow
       device owner to mount), and ``comment'' (e.g., for use  by fstab-main-
       taining  programs).   The  ``owner'' and ``comment'' options are Linux-
       specific.  For more details, see mount(8).

Example fstab line:

/dev/sdc1      /mnt/shared     vfat uid=myuseruid,gid=myusergid 0 0

(where myuseruid and myusergid are numbers)

'Hope that helps.

Bonus tip:  In that or any/all other mountpoint directories, 
go there with root access (with nothing mounted at the mountpoint) and


This creates a zero-length, root-owned file of that name.  Point is,
it's a visual indicator.  Any files within a mountpoint are
automatically rendered invisible while something is mounted at the
mountpoint, and return to visibility the moment the filesystem gets

Do that, and you'll thank yourself, the day you're too tired to notice
that the reason a tree is suddenly mysteriously empty is that what's
supposed to be mounted there, isn't.

More information about the sf-lug mailing list