Created
June 3, 2022 01:01
-
-
Save konsumer/d56e7f15788061e23d2cbc3234359637 to your computer and use it in GitHub Desktop.
make a debian-based os image and chroot for arm (run in arm64 qemu)
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 -e | |
apt install -y build-essential debootstrap unzip git | |
# create image | |
qemu-img create -f qcow2 -o preallocation=metadata rknullos.qcow2 2G | |
modprobe nbd max_part=8 | |
qemu-nbd --connect=/dev/nbd0 rknullos.qcow2 | |
# paritition | |
cat << EOF | sfdisk /dev/nbd0 | |
/dev/nbd0p1 : start= 2048, size= 204800, type=6 | |
/dev/nbd0p2 : start= 206848, size= 3987456, type=83 | |
EOF | |
# setup filesystem | |
mkfs -j /dev/nbd0p2 | |
mkfs -t fat /dev/nbd0p1 | |
mkdir root | |
mount /dev/nbd0p2 root | |
mkdir -p root/boot | |
mount /dev/nbd0p1 root/boot | |
debootstrap bullseye root http://deb.debian.org/debian/ | |
echo "type exit to leave the chroot" | |
chroot root bash | |
# cleanup | |
umount root/boot | |
umount root | |
qemu-nbd --disconnect /dev/nbd0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment