Skip to content

Instantly share code, notes, and snippets.

@fripSide
Last active July 27, 2023 17:35
Show Gist options
  • Save fripSide/93882d4b6740875be1203380c5d5b756 to your computer and use it in GitHub Desktop.
Save fripSide/93882d4b6740875be1203380c5d5b756 to your computer and use it in GitHub Desktop.
Run the arm32 VM (debian armhf) with Qemu
copy boot/vlinuz /boot/initrd.gz
# Download all necessaries files into the `files` folder
# This script is taken from https://www.willhaley.com/blog/debian-arm-qemu/
pushd .
mkdir -p files && cd files
curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-armhf/current/images/cdrom/initrd.gz
curl -O http://ftp.us.debian.org/debian/dists/stable/main/installer-armhf/current/images/cdrom/vmlinuz
curl -O -L https://cdimage.debian.org/debian-cd/current/armhf/iso-dvd/debian-12.1.0-armhf-DVD-1.iso
if [ !f hd_image.img ]; then
qemu-img create -f qcow2 hd_image.img 100G
fi
popd
# This script is modified from Debian's Wiki [2] as the commands in [1] failed to find the cdrom media.
# [1] https://www.willhaley.com/blog/debian-arm-qemu/
# [2] https://wiki.debian.org/DebianInstaller/Qemu
# Notes:
# The frist time of running VM needs more than half an hour to install the OS from the cmdrom (iso file) to file system (hd_image.img).
# I put a
# Step-1: installing Debian
qemu-system-arm \
-M virt -m 4G \
-cpu cortex-a7 -smp 4 \
-kernel files/vmlinuz \
-initrd files/initrd.gz \
-drive file=files/debian-12.1.0-armhf-DVD-1.iso,if=none,id=cd,media=cdrom,read-only=on \
-device virtio-blk-device,drive=cd \
-drive file=files/hd_image.img,if=none,id=hd \
-device virtio-blk-device,drive=hd \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \
-nographic
# Step-2: after install debian
qemu-system-arm \
-M virt -m 4G \
-cpu cortex-a7 -smp 4 \
-initrd "files/initrd.gz" \
-kernel "files/vmlinuz" \
-append "console=ttyAMA0 root=/dev/sda2" \
-drive file=hd_image.img,if=none,id=hd,media=disk \
-device virtio-scsi-device \
-device scsi-hd,drive=hd \
-device virtio-net-device,netdev=net0 \
-netdev user,id=net0,hostfwd=tcp::5555-:22 \
-nographic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment