[systemd-devel] systemd-nspawn: where is my container root?

Lennart Poettering lennart at poettering.net
Thu Jun 28 20:17:33 UTC 2018


On Do, 28.06.18 20:25, Nikolaus Rath (Nikolaus at rath.org) wrote:

> On Jun 26 2018, Lennart Poettering <lennart at poettering.net> wrote:
> > On Di, 26.06.18 09:39, Nikolaus Rath (Nikolaus at rath.org) wrote:
> >
> >> Hi,
> >> 
> >> That makes sense.. but is there any way to find out *globally* what
> >> devices are mounted in *any* namespace?
> >
> > If you a PID from any process that belongs to the container you can
> > list its mounts by doing /proc/$PID/mountinfo. You can also access its
> > files through the /proc/$PID/root pseudo directory. 
> >
> > There's also /usr/lib/systemd/systemd-dissect --mount if you want to
> > look into a raw image and have it mounted externally just like
> > systemd-nspawn would do it.
> 
> That's good to know, thanks! My question was meant a little different
> though (and is probably somewhat off-topic, but it fit nicely into the
> thread):
> 
> If any process could potentially sit in its own namespace (whether
> created by systemd or manually) and have its own mounts, is there any
> way for me to get a list of *all* the mounts in any namespace (without
> having to determine which pids have their own namespace and query
> them one by one)?

Try this:

for f in /proc/*/mountinfo ; do cat $f ; done | sort -un 

it will output a list of all mounts in all processes on the system,
neatly sorted by the numeric mount id.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list