Last active
March 19, 2020 00:07
-
-
Save bahamat/33349eb5cd230ae479b2e8f02e987c4c to your computer and use it in GitHub Desktop.
chroot in lx brand zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# MIT License. | |
# This isn't meant to be run as a script exactly, but github has better syntax hilighting if I pretend. | |
chr=${PWD}/testroot | |
mkdir -p $chr/{bin,lib,lib64,native,var} | |
cd $chr | |
cp -v /bin/{bash,touch,ls,rm} $chr/bin | |
list=( | |
$(ldd /bin/bash | egrep -o '/lib.*\.[0-9]') | |
$(ldd /bin/touch | egrep -o '/lib.*\.[0-9]') | |
$(ldd /bin/ls | egrep -o '/lib.*\.[0-9]') | |
$(ldd /bin/rm | egrep -o '/lib.*\.[0-9]') | |
) | |
list=( $(tr ' ' '\n' <<< "${list[@]}" | sort -u | tr '\n' ' ') ) | |
for i in ${list[@]} ; do cp -v --parents "$i" "${chr}"; done | |
/native/usr/sbin/mount -O -F lofs /native ${chr}/native/ | |
cp -v --parents /var/ld/64/ld.config $chr | |
# You're ready, now run it. | |
chroot $chr bin/bash |
To prune the chroot, make sure to unmount /native
first.
umount ${chr:?}/native
rm -rf ${chr:?}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The key to using a chroot on lx-brand is that you need:
/native
mounted inside of your chroot/var/ld/64/ld.config