Okay, latest update.
I’ve made some good progress. I’m now running a Debian buster
VM on QEMU on the Mac M1.
I ran this to get to the installer:
qemu-system-aarch64 \
-machine virt,accel=hvf,highmem=off \
-cpu cortex-a72 -smp 8 -m 4G \
-device intel-hda -device hda-output \
-nographic \
-device usb-ehci \
-device usb-kbd \
-device virtio-net-pci,netdev=net \
-device virtio-mouse-pci \
-netdev user,id=net,ipv6=off \
-drive "if=pflash,format=raw,file=./edk2-aarch64-code.fd,readonly=on" \
-drive "if=virtio,format=raw,file=./hdd.raw,discard=on" \
-drive "file=../debian/debian-10.9.0-arm64-netinst.iso,id=cdrom,if=none,media=cdrom" \
-device virtio-scsi-device -device scsi-cd,drive=cdrom \
-boot order=d
followed the usual Debian installation steps. Then I can just remove the SCSI cdrom device and use QEMU to boot from the hdd.raw
file itself which now contains a bootable Debian. I did have to manually get the QEMU UEFI to load the grubaa64.efi
but that’s a bit beside the point… (I am keeping track of all the commands I am running, and what each part does so I can write a nice post for future M1 users).
This works much better with the grml-debootstrap
package, it now finishes building in a few minutes. Thanks @Patrick! In order to get a successful run, I’ve used the below command:
sudo KERNEL='none' NOKERNEL='true' UPGRADE_SYSTEM='no' GRUB_INSTALL='no' grml-debootstrap \
--debopt "--verbose --include=initramfs-tools,eatmydata,apt-transport-tor,python3.7,gpg,gpg-agent" \
--arch arm64 \
--filesystem ext4 \
--force \
--hostname host \
--nopassword \
--release buster \
--keep_src_list \
--verbose \
--vmfile \
--vmsize 25G \
--packages ./grml_packages \
--target ./debian.raw
I’ve made this based on these whonix build steps.
This provides me with a debian.raw file. I understand that this does not have grub (if I don’t use GRUB_INSTALL='no'
the build fails), nor a kernel (same here, if I don’t pass KERNEL='none' NOKERNEL='true'
) the build fails.
The reason for these failures (as far as I can tell) is that grml-debootstrap
does not natively support arm64.
I know that I now need to get arm64 grub and an arm64 kernel onto this VM file. So far I’ve tried two things (neither of which worked).
- Mount the
debian.raw
file and try rungrub-install
.
sudo mkdir -p "/mnt/debootstrap.grub"
sudo kpartx -asv ./debian.raw
sudo mount -o rw,suid,dev "/dev/mapper/loop0p1" "/mnt/debootstrap.grub"
sudo grub-install /mnt/debootstrap.grub --target arm64-efi
sudo sync
sudo umount /mnt/debootstrap.grub
sudo kpartx -d ./debian.raw >/dev/null
sudo rmdir /mnt/debootstrap.grub
sudo chown user:user ./debian.raw
Unfortunately I didn’t see any relevant grub files in the /mnt/debootstrap.grub/boot
folder.
So, then I tried…
- Copy the files I have from my working Debian VM’s
/boot
folder into the mounted Debian filesystem’s boot folder (i.e./mnt/debootstrap.grub/boot
). This meant mydebian.raw
file now has (what looks like) the files necessary for booting. However, running this in a similar qemu command as above yields a UEFI error.
I know UEFI generally looks for an EFI partition (I have some experience in hackintoshing). However, I’m not really use how to go about making this partition in a file. Maybe that’s the reason the QEMU UEFI BIOS cannot find the required grubaa64.efi
file?
I’m still continuing my trials. Just wanted to leave another update as I progress.
Note: @HulaHoop, seems I can use edk2-aarch64-code.fd
to boot arm64 debian. Working well for me so far with the Debian VM I created using the net installer. I suppose this then should work when I can get a correct build from grml-debootstrap
. Thanks though!
EDIT: quick update. Figured out I need to get that new partition setup and also probably make changes to /etc/fstab
.
Some helpful resources I am going to use next to try get my debian.raw
booting are:
Also seems it’s not too dissimilar to what this script does: https://gitlab.com/whonix/Whonix/-/blob/master/build-steps.d/2375_build_rpi_fs#L22
So, will report back once I’ve exhausted my efforts there.
And, finally, I suppose once I do have a way of getting this working we feed that back into a new script in the build-steps.d
folder.