Youโll be running scripts in ./scripts
, either one by one or all together via ./run-all.sh
.
The scripts are templates โ you may need to complete missing parts (search for TODO
s)!
Yes, really, you can easily do this!
You will use the debootstrap official tool to install a minimal Debian (you can also install deb-based derivatives like Ubuntu!) base system.
๐ Edit the 05-debootstrap.sh
script.
Since we need to install the Debian binaries executable on a 64-bit ARM architecture, we will need to split the installation into two stages: first, the .deb (Debian install packages) are downloaded from a Debian mirror server and unpacked into the target rootfs directory. Afterwards, since Debian will need to run some scripts to setup its distro system, we must emulate the target architecture. Enter qemu which will help us to just that!
Finally, we need to obtain the artifacts/debrootfs.tar.gz
archive with the contents of our newly-created Aarch64 Debian. Use tar
to c
reate a gz
ipped archive, and be sure to p
reserve permissions!
The final results should be something like:
-rw-r--r-- 1 root root 148M 2025-08-07 14:23 debrootfs.tar.gz
๐ File: 10-create-base-disk.sh
Your task:
truncate
or dd
to allocate the image with the desired size;parted
invocation (script);
๐ File: 25-populate-base-disk.sh
Subtasks:
debrootfs.tar.gz
on each rootfs A/B partition (a simple tar xf
will suffice);
Note: you will lack flash_emmc.bin
required by this script. So let's proceed without testing, for now.
If you wish to enter your newly bootstrapped Debian rootfs, you can use the following script:
#!/bin/bash set -e ROOTFS=$1 if [[ -z "$ROOTFS" ]] || [[ ! -d "$ROOTFS/usr/bin" ]]; then echo "[!] Invalid rootfs argument: '$ROOTFS'" exit 1 fi cleanup() { echo "[*] Cleaning up..." for sub in dev/pts dev proc sys run; do if mountpoint -q "$ROOTFS/$sub"; then echo " Unmounting $ROOTFS/$sub" sudo umount "$ROOTFS/$sub" || true fi done } trap cleanup EXIT echo "[+] Binding chroot filesystems..." for fs in dev dev/pts proc sys run; do sudo mount --bind "/$fs" "$ROOTFS/$fs" done echo "[+] Ensuring /etc/resolv.conf for DNS inside chroot" sudo cp /etc/resolv.conf "$ROOTFS/etc/resolv.conf" echo "[+] Entering your chroot shell..." echo "Type exit to leave" sudo chroot "$ROOTFS" /usr/bin/qemu-aarch64-static /bin/bash
You can even run apt install
in there ;)