Skip to content

Instantly share code, notes, and snippets.

@Azkali
Last active December 20, 2023 23:29
Show Gist options
  • Select an option

  • Save Azkali/f5dd103f1b260370983ac8e83b93f757 to your computer and use it in GitHub Desktop.

Select an option

Save Azkali/f5dd103f1b260370983ac8e83b93f757 to your computer and use it in GitHub Desktop.
wsl-chroot
#!/bin/bash
[ $(id -u) != 0 ] && exit
[ ! -d $1 ] && exit
daemonize /usr/bin/unshare -fp --mount-proc /lib/systemd/systemd --system-unit=basic.target
cat /usr/lib/binfmt.d/qemu-aarch64-static.conf | tee /proc/sys/fs/binfmt_misc/register > /dev/null
cp /usr/bin/qemu-aarch64-static $1/usr/bin/
mount -o bind /proc $1/proc
mount -o bind /dev $1/dev
chroot $1 bash
rm $1/usr/bin/qemu-aarch64-static
umount -lR $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment