What you want is possible by utilizing kernel namespaces capability and IMO if you recreate your filesystem namespace from scratch which requires some plumbing ... However, luckily, there is a tool from the package bubblewrap
that can do that fairly easy:
bwrap is a privileged helper for container setup. You are unlikely to
use it directly from the commandline, although that is possible.
It works by creating a new, completely empty, filesystem namespace
where the root is on a tmpfs that is invisible from the host, and
which will be automatically cleaned up when the last process exits.
You can then use commandline options to construct the root filesystem
and process environment for the command to run in the namespace.
Therefore:
bwrap --die-with-parent --bind / / --dev-bind /dev /dev --bind /home/rtetteh/.local/ts /ts -- /bin/bash
Is the minimum example(as I see it) to do what you want ... Read the manual and expand that example with more options as you need like for example --setenv VAR VALUE
to set environment variables when needed.
If you need to add more bind mounts, then you can add them before the last --
in the form of --bind SRC DEST
... And you will always need --bind / / --dev-bind /dev /dev
so don't remove or modify them.
Needless to say that you can't use system directories like /etc
, /bin
or /var
... etc. as target mount points for other directories or otherwise your newly created filesystem namespace will become unstable and probably unusable.
That wont affect other users or the system services and will only affect the newly created filesystem namespace.