Step into a Foreign Image¶
apt install qemu-user-static
update-binfmts --display
arch="aarch64"
mnt="$(readlink -f ./mnt)"
mkdir -p "${mnt}"
# mount the target filesystem on ${mnt}
mount -t devtmpfs devtmpfs "${mnt}/dev"
mount -t devpts devpts "${mnt}/dev/pts"
mount -t tmpfs tmpfs "${mnt}/dev/shm"
mount -t proc proc "${mnt}/proc"
mount -t sysfs sysfs "${mnt}/sys"
mount -t tmpfs tmpfs "${mnt}/tmp"
mkdir ./overlay
mount -t tmpfs tmpfs ./overlay
mkdir ./overlay/{workdir,upperdir,mnt}
mount -t overlay -o lowerdir="$(readlink -f "./mnt/")",upperdir="$(readlink -f "./overlay/upperdir/")",workdir="$(readlink -f "./overlay/workdir/")" overlayfs ./overlay/mnt
cp "/usr/bin/qemu-${arch}-static" ./overlay/mnt/usr/bin/
chroot ./overlay/mnt/ /bin/sh
Work!
umount ./overlay/mnt
umount ./overlay
umount "${mnt}/tmp"
umount "${mnt}/sys"
umount "${mnt}/proc"
umount "${mnt}/dev/shm"
umount "${mnt}/dev/pts"
umount "${mnt}/dev"
umount "${mnt}"
See step_in.sh
.