Raspberry virtual machine from sdcard (linux/mac)
Jul 27, 2017 · 1 min read
If for whatever reason you need to setup Raspberry Pi Zero W without keyboard :)
Note: This will actually emulate Raspberry Pi 2 (different version) but it doesn't matter much because all I wanted was to run raspbian in qemu and make some changes to its fs.
Download latest raspbian

Flash to sdcard using Etcher (or whatever else)
Get qemu
brew install qemuGet kernel and device tree from the first (vfat) partition of your sdcard.
cp /Volumes/boot/{*.img,*.dtb} ./Start qemu with io forwarded to your terminal
# optionally unmount /dev/disk2 first
# Mac: sudo diskutil unmountDisk /dev/disk2sudo qemu-system-arm \
-no-reboot \
-serial stdio \
-machine raspi2 -m 256 \
-dtb ./bcm2709-rpi-2-b.dtb \
-kernel ./kernel7.img \
-drive file=/dev/disk2,format=raw \
Setup network
sudo vi /etc/wpa_supplicant/wpa_supplicant.confEnable ssh
sudo raspi-configShutdown and boot with regular raspberry pi.
sudo shutdown now