[systemd-devel] Booting to systemd in a chroot

Lennart Poettering lennart at poettering.net
Thu May 14 09:25:39 PDT 2015


On Thu, 14.05.15 06:12, JT Olds (jtolds at xnet5.com) wrote:

> Hey folks!
> 
> I'm getting lots of systemd errors like
> `Failed at step NAMESPACE spawning /usr/lib/rtkit/rtkit-daemon: Invalid
> argument` and just wondering what I'm doing wrong.
> 
> For background: I have a linux computer that's running Debian Wheezy. I
> want to install and dual boot Jessie, but without creating a new partition,
> so I want to do it in a chroot (cause why not, I should be able to,
> right?). 

Sorry, but this simply cannot work: a chroot() is too weak, and
doesn't mix well with file system namespacing (which triggers the
errors you are seeing). Proper file system namespacing hides the fact
pretty well that things are namespaced, but chroot does
not. Especially if you then mix namespacing and chroot things become
ugly...

Hence, please do not use chroot for what you are trying to do. Please
either use namespacing (i.e. mount --move) or privot_root() for this.

> I ran `debootstrap jessie /jessie` and got a full Jessie
> installation in that subfolder (via tasksel and everything). I then edited
> GRUB to have a menu option that boots linux like this:
> 
> linux /jessie/vmlinuz root=UUID=<uid> rw init=/jessie/chrootinit
> initrd /jessie/initrd.img
> 
> Last, I created chrootinit that wraps systemd:
> 
> #!/bin/bash
> exec chroot /jessie /sbin/init "$@"

This should work fine if you use pivot_root instead of chroot. Both
tools are part of util-linux.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list