Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question

4 Answers 4

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|improve this answer
1  
I should have mentioned it, but I can't use tmpfs. tmpfs can be paged out to disk, which I need to avoid. –  Jonathon Reinhart Oct 17 '11 at 16:51

If you want to avoid sudo you could use the automounter here (service autofs). Look for executable automount-maps. There you can script anything you want before, during and after the actual mount.

share|improve this answer

It is generally somewhat dangerous to give non-root acces to a ramfs mount, since a (malicious/ignorant) user could put enough data into it to fill all available system RAM. Like others above have mentioned, something like tmpfs or even a ram disk might be more desirable for non-root use. (sr_'s post has some really good reads.)

share|improve this answer
1  
Incorrect, ramfs has a max size option –  Bryan Hunt May 9 '12 at 18:44
    
@BryanHunt source? Because I read this everywhere. "A ramfs derivative called tmpfs was created to add size limits" –  redanimalwar Nov 8 at 16:33

After you mount the ramdisk, /home/jreinhart/ramdisk becomes the root of the mounted filesystem. Apparently this directory is owned by root. Change it (and any other relevant file on the ramdisk) once and for all to be owned by jreinhart.

You may have seen a different behavior for filesystems like vfat. On filesystems that have no notion of ownership, the filesystem driver tries to come up with sensible fake ownership, generally making every file owned by the user who mounted the filesystem. Filesystems like ramfs that provide normal unix permissions expose them directly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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