13

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
  • My opinion is that uid=www-data is more portable than uid=33. – ott-- Aug 20 '13 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. – Jeff Aug 20 '13 at 19:41
12

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)).

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.