remount /tmp for the current shell
Solution 1:
The unshare command can do pretty much what you are asking for:
unshare -m "$SHELL"
After that you can change any mounts you like locally to that shell only.
I recommend that any mount commands you run inside the unshared shell use the -n
flag, because otherwise it will change /etc/mtab
which will be visible to the entire system. You probably want df
and mount
commands run outside that shell to still show the correct file system mounted on /tmp
.