mount ramfs as user

7,429

Solution 1

I had the same problem. Using mode=777 instead of umask=777 as an option seems to work (Ubuntu 15.10).

Solution 2

Assuming this is Linux, you could also use tmpfs (see here for differences, i.e., why it might be advisable to use tmpfs), which is explained here and (see link) supports the options mode, gid and uid. There's the following paragraph in tmpfs.txt which might also be relevant:

These options do not have any effect on remount. You can change these
parameters with chmod(1), chown(1) and chgrp(1) on a mounted filesystem.

So maybe a sudo chown ... is still needed (I guess not, but I'm not quite sure about this, sorry.)

Share:
7,429

Related videos on Youtube

Jonathon Reinhart
Author by

Jonathon Reinhart

Professional C, asm, Python developer GitLab, FreeNas admin

Updated on September 18, 2022

Comments

  • Jonathon Reinhart
    Jonathon Reinhart over 1 year

    My fstab entry:

    none    /home/jreinhart/ramdisk    ramfs    defaults,user   0 0
    

    The directory before mounting:

    drwxrwxr-x  2 jreinhart jreinhart  4096  Oct 17 11:31 ramdisk
    

    The directory after mount ramdisk:

    drwxr-xr-x  2 root     jreinhart  4096  Oct 17 11:31 ramdisk
    

    So, you can see the problem. Once I mount, the owner changes to root, and the group permissions go to r-x so I cannot use this ramdisk. What gives?

    I'm trying to do this without having to su.

  • Jonathon Reinhart
    Jonathon Reinhart over 12 years
    I should have mentioned it, but I can't use tmpfs. tmpfs can be paged out to disk, which I need to avoid.
  • Bryan Hunt
    Bryan Hunt about 12 years
    Incorrect, ramfs has a max size option
  • redanimalwar
    redanimalwar over 9 years
    @BryanHunt source? Because I read this everywhere. "A ramfs derivative called tmpfs was created to add size limits"
  • DepressedDaniel
    DepressedDaniel over 7 years
    Except that it's not "once and for all" as the ramfs contents are lost when it is unmounted. OP probably wants the permissions to persist across reboots, which is why he is giving us an fstab entry to look at.
  • Neurotransmitter
    Neurotransmitter over 7 years
    This is the sole right answer. So the OP's fstab entry may look like this: none /home/jreinhart/ramdisk ramfs user,noauto,size=1024M,mode=0770 0 0. I removed defaults since it somewhat contradicts to user (it implies plenty of other options) and tuned mode to a more safe world-non-readable 0770 mask (so only root and jreinhart may read and write to this).