https://1xv447d.257.cz/posts/2022-04-29-raspbian-emulation-in-qemu
https://www.raspberrypi.com/software/operating-systems/
- Install QEMU system emulation binaries for ARM processors
sudo apt-get qemu-system-arm
- Create new folder and put these downloads in it
mkdir Wombat-Bullseye
-
Download Pi Image with desktop and unzip to Wombat-Bullseye
-
Change image name to Wombat-Bullseye
mv 2022-09-06-raspios-bullseye-arm64-lite.img Wombat-Bullseye.img
- Mount the partitions
sudo losetup --show --find --partscan Wombat-Bullseye.img
sudo mkdir /mnt/{raspbian-boot,raspbian-root}
sudo mount /dev/loop1p1 /mnt/raspbian-boot;
sudo mount /dev/loop1p2 /mnt/raspbian-root
- Create a userconf.txt file and copy it to raspbian-boot (you can change the password and username if desired)
touch userconf.txt ;
echo -n 'kipr:' > userconf.txt ;
echo 'botball' | openssl passwd -6 -stdin >> userconf.txt
sudo cp userconf.txt /mnt/raspbian-boot/userconf.txt
- Copy the kernel device tree file to Wombat-Bullseye
sudo cp /mnt/raspbian-boot/bcm2710-rpi-3-b.dtb .;
sudo cp /mnt/raspbian-boot/kernel8.img .
- Unmount the image
sudo umount /dev/loop1p1;
sudo umount /dev/loop1p2;
sudo rmdir /mnt/{raspbian-boot,raspbian-root};
sudo losetup --detach /dev/loop1
- Convert image to qcow2 format
qemu-img convert -f raw -O qcow2 Wombat-Bullseye.img Wombat-Bullseye.qcow2
- Increase disk size to 8G (or whatever size your SD card is) using qemu-img
- Warning: It may be a good idea to create a backup copy of the image before resizing it at this point
qemu-img resize Wombat-Bullseye.qcow2 8G
- Create Wombat_Start.sh to run with correct dtb and kernel (or use the one in the repository)
#!/usr/bin/env bash
sudo qemu-system-aarch64 \
-M raspi3b \
-m 1024 \
-kernel kernel8.img \
-dtb bcm2710-rpi-3-b.dtb \
-drive "format=qcow2,file=Wombat-Bullseye.qcow2" \
-append "console=ttyAMA0 root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4" \
-device usb-net,netdev=net0 -netdev user,id=net0,hostfwd=tcp::5555-:22 \
-serial stdio -usb -device usb-mouse -device usb-kbd
- Run Wombat_Start.sh
./Wombat_Start.sh
- After logging in enable ssh on bootup
sudo systemctl enable --now ssh.service
- You can remain in this terminal or you can also connect locally
ssh kipr@127.0.0.1 -p 5555
- Run fdisk to recreate the second partition
sudo fdisk /dev/mmcblk0
- In fdisk, run these commands:
To show the current disk layout (note the starting sector of the second partition)
print
Delete the old partition 2
d
2
Create a new partition and make it the primary partition
n
p
2
Put in the starting sector of the old partition and enter to accept
xxxxx
Answer no to changing ext4 signature
n
Write all changes to disk and exit fdisk
w
- Complete the resizing operation
sudo resize2fs /dev/mmcblk0p2
- Confirm expanded disk size
df -h
- Get updates now that there is enough space for them
sudo apt-get update
sudo apt-get upgrade