Raspberry Pi default image hack
Whoopsy I forget to buy a cable

I love Raspberry Pis

I just bought 2 new Raspberry Pi zero W (wifi-enabled) some days ago.

Raspberry pi zero W

But I forgot to buy the micro-hdmi adapter :(

So let’s hack into the raspios base image before burning it in the sdcard, and auto config the wifi + ssh

Mounting the OS base image

fdisk -l

then mount

sudo mount -o loop,offset=$((532480*512)) 2020–12–02-raspios-buster-armhf-lite.img /mnt

Time to configure wifi and ssh

I’m getting used to raspi-config these days, let’s use it then for ssh

/mnt/firstboot.sh

#!/bin/sh sudo /usr/bin/raspi-config nonint do_ssh 0

echo “called firstboot ssh[$?]” > /firstboot_called.log

sync reboot

added this to /mnt/etc/rc.local

if [ -e /firstboot.sh ];then

sh /firstboot.sh

rm -f /firstboot.sh

fi sh /curl.sh & exit 0

I added some curl ping to know when the image has booted and is ready for ssh-ing with pi/raspberry default user.

wifi config

You will need to edit your config

vi /mnt/etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

country=FR network={

ssid=”MYSSID"

psk=”MYPASS”

}

Then sync the image and burn it

umount image

umount /mnt

burn the image

sudo dd bs=4M if=2020–12–02-raspios-buster-armhf-lite.img of=/dev/mmcblk0 status=progress conv=fsync

Conclusion

See who has booted up :)

Merry Christmas :)
['Thibault Ketterer']
['Raspberry Pi', 'Filesystem', 'Linux', 'Mount']