Skip to contentSkip to conversation

initramfs-framework: overlayroot: switch_root instead of chroot

PATCH New Marcus Flyckt 1 participant 1 message May 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 initramfs-framework: overlayroot: switch_root instead of chroot

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.

---
 meta/recipes-core/initrdscripts/initramfs-framework/overlayroot | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/initrdscripts/initramfs-framework/overlayroot +1 -1
index dacbcbe213..3f0a1c5493 100644
@@ -114,4 +114,4 @@ mount -n --move /proc ${NEWROOT}/proc
 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"
Signature · 1 line
2.43.0