Use a proper switch_root instead of a plain chroot when transitioning to
the overlay root filesystem.
Some Linux features, like unshare(2), check for chrooted
environments and may return EPERM when running inside one.
This is particularly an issue when running unprivileged containers.
Signed-off-by: Marcus Flyckt <marcus.flyckt@kvaser.com>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
mount -n --move /sys ${NEWROOT}/sys
mount -n --move /dev ${NEWROOT}/dev
-exec chroot ${NEWROOT}/ ${bootparam_init:-/sbin/init} || exit_gracefully "Couldn't chroot into overlay"
+exec switch_root ${NEWROOT}/ ${bootparam_init:-/sbin/init} || exit_gracefully "Couldn't switch_root into overlay"