0

Is it possible to run a SystemD service with a different root? For example if I use debootstrap to install a parallel distro, and inside that distro is a systemd service I would like to run, is there a way to configure systemd in the host to do it?

I see WorkingDirectory in the script currently.

1 Answer 1

5

SystemD supports this through RootDirectory,

RootDirectory= Takes a directory path relative to the host's root directory (i.e. the root of the system running the service manager). Sets the root directory for executed processes, with the chroot(2) system call. If this is used, it must be ensured that the process binary and all its auxiliary files are available in the chroot() jail. Note that setting this parameter might result in additional dependencies to be added to the unit (see above).

The MountAPIVFS= and PrivateUsers= settings are particularly useful in conjunction with RootDirectory=.

APIVFS, is probably the most useful,

Takes a boolean argument. If on, a private mount namespace for the unit's processes is created and the API file systems /proc, /sys, and /dev are mounted inside of it, unless they are already mounted

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .