3

I have this in my /etc/fstab:

tmpfs   /home/user1/tmp tmpfs  rw,nodev,nosuid,noexec,size=16G  0   0

user1 has tmpfs mounted as /home/user1/tmp.

I would like to mount same tmpfs for user2 as well, so that they can share same tmpfs.

How can I do this in fstab, so that user2 has same tmpfs mounted at /home/user1/tmp ?

400 the Cat
  • 819
  • 4
  • 37
  • 85
  • Don't you also have a `uid` option in your `fstab`? In other words, is the mounted tmpfs currently only accessible to root? What should eventually be the two users' access permissions to the tmpfs? – fra-san May 28 '20 at 16:04
  • @fra-san - thank you, you are right. I have removed the mode because it is no relevant here. But in my real fstab, I have mode,uid, and gid – 400 the Cat May 28 '20 at 16:19
  • I believe the permissions you're expecting `user1` and `user2` to have over the mounted tmpfs are relevant: for instance (on Linux -- you didn't specify your platform, which may be relevant too), you may just symlink `/home/user1/tmp` and `/home/user2/tmp` [to `/dev/shm`](https://unix.stackexchange.com/q/26364/315749) (or bind-mount it), if you're OK with its sticky bit - i.e. both users can read everything but only edit and remove files and directories they own. – fra-san May 28 '20 at 17:03
  • @fra-san - I cannot symlink, because the users don't have access to each others homes. Anyway, please forget about permissions. This is not the issue here. I know how to fix that myself. – 400 the Cat May 28 '20 at 17:06

1 Answers1

2

Add another line with a bind mount:

/home/user1/tmp /home/user2/tmp none bind,x-systemd.requires=/home/user1/tmp

The systemd is just for ordering, but you may not need/want it.

meuh
  • 49,672
  • 2
  • 52
  • 114