20

I'm learning how to set up a tmpfs in fstab for my www-data user and I was wondering if I can use the actual user/group name instead if the numeric ids (personal preference)?

I'm on Debian with ext4, formatted with "msdos" during setup.

It seems to be working, but I'm wondering if this is a Debian-specific feature or will it work across platforms (I like portability)?

Here's what I've got:

$ vim /etc/fstab # PHP temporary files. tmpfs /tmpfs/php-session tmpfs defaults,size=512M,mode=1700,uid=www-data,gid=www-data,noexec,nodev,nosuid 0 0 tmpfs /tmpfs/php-upload tmpfs defaults,size=256M,mode=1700,uid=www-data,gid=www-data,noexec,nodev,nosuid 0 0 
2
  • My opinion is that uid=www-data is more portable than uid=33. Commented Aug 20, 2013 at 19:26
  • Agree. I can't find any documentation on this and no examples of it in practice. If it's portable across OS's, partition types and format types, I'm going to run with it. Commented Aug 20, 2013 at 19:41

3 Answers 3

16

The Linux mount program interprets non-numeric parameters to uid and gid options as user and group names respectively. This applies to all filesystem types. It works both if the options come from the command line and if they come from /etc/fstab.

Source: source (old (parse_opt), new (mnt_optstr_fix_gid, mnt_optstr_fix_uid)).

0
9

If you are using an ext filesystem, the uid and gid options are ignored, as the permissions used are set by the filesystem.

To quote gilles from another answer:

On an ext4 filesystem (like ext2, ext3, and most other unix-originating filesystems), the effective file permissions don't depend on who mounted the filesystem or on mount options, only on the metadata stored within the filesystem.

One method to resolve this would be to chown or chgrp the filesystem at some point when mounted.

1

Kind of a hack way in my opinion but what I did was in my /mnt path I have /mnt/somefolder, what i did was manually create that folder before mounting anything, then changing the owner and group to my uid/gid. Then everytime fstab mounts, it retains those permissions/ownership.

ie.

sudo mkdir /mnt/somefolder #get uid and gid id -u id -g #change ownership sudo chown {uid}:{gid} /mnt/somefolder #now mount with what you have set up in fstab sudo mount -a 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.