7.2. Reset Target Tree Ownership to root
Before entering chroot, hand ownership of the entire target tree back to root so in-chroot package work runs with expected permissions.
Goal: make the whole
$LBI_ROOT tree owned by root:root before entering chroot.
In earlier setup, ownership of the target tree may have been handed to a normal user to simplify build steps. At this point, before entering chroot, ownership should be reset to root recursively.
All commands in this section must be run as the root user.
Become root
Use whichever privilege method your host uses:
# Option 1: sudo
sudo -i
# Option 2: doas
doas -s
# Option 3: su
su -
Reset ownership of the whole target tree
chown -R root:root "$LBI_ROOT"
That command should cover the entire target tree under $LBI_ROOT, including directories, files, and symlinks, so ownership is consistent before chroot work begins.
Safety check: verify
$LBI_ROOT is set to the intended mounted target path before pressing Enter. Running recursive chown against the wrong path is an excellent way to ruin your day.
Command Explanations
sudo -i,doas -s, andsu -: Show common ways to open a root shell before changing ownership of the target tree.chown -R root:root "$LBI_ROOT": Recursively changes the target tree ownership to root so the chroot starts with normal system ownership instead of the build user.