chroot to an aarch64 file system in ubuntu x86 architecture distribution , with qemu user static and binfmt support tools - zhouyoujoin/ubuntu GitHub Wiki

#1. Install qemu-user-static and binfmt-fmt

sudo apt-get install qemu-user-static
sudo apt-get install binfmt-support

#2. Define the downloads and workspace path

export ws_path=~/Workspace/ubuntu-x86-chroot-arm64
export iso_path=~/Downloads/Ubuntu
export iso_mount_point=~/Workspace/ubuntu-16.04.3-arm64-cdtmp

#3. Downloading ubuntu 16.04.3 LTS server edition for arm64, and then mount it to local directory

mkdir -p $iso_path
cd $iso_path
wget http://old-releases.ubuntu.com/releases/16.04.4/ubuntu-16.04.3-server-arm64.iso

mkdir -p $iso_mount_point
sudo mount -o loop $iso_path/ubuntu-16.04.3-server-arm64.iso $iso_mount_point

#4. Fetch the orignal squash filesystem from the iso file

mkdir -p $ws_path
cd $ws_path
sudo unsquashfs $iso_mount_point/install/filesystem.squashfs

!after this step, we got a directory named "squashfs-root", the original arm64 ubuntu file system.

#5. Make chroot available on the x86 environment for arm64 ubuntu filesystem

cp /usr/bin/qemu-aarch64-static $ws_path/squashfs-root/usr/bin
sudo chroot $ws_path/squashfs-root /bin/bash

!Ahah, successfully chroot to an aarch64 filesytem on x86 architecture.