based on https://opensource.com/article/21/7/custom-raspberry-pi-image
- First image the raspberry pi and make any changes you need via SSH. When you're done make sure to install cockpit:
sudo apt install cockpit
- Next plug in the SD card into your mac and list the attached disks:
diskutil list
- We need to unmount the attached disks like so:
diskutil unmount /dev/disk4s1
diskutil unmount /dev/disk4s2
- Next copy the contents of that disk into an image file, you can call
raspberry-pi-image.img
whatever you want.
sudo dd if=/dev/disk4 of=raspberry-pi-image.img bs=32M
- Next shrink down the image with pishrink
- Installer Docker.
- Clone this repo and cd into the pishrink directory:
git clone https://github.com/Drewsif/PiShrink && cd PiShrink
- Build the container by running:
docker build -t pishrink .
- Create an alias to run PiShrink:
echo "alias pi-shrink='sudo docker run -it --rm --platform linux/amd64 --privileged=true -v $(pwd):/workdir pishrink'" >> ~/.bashrc && source ~/.bashrc
- run it
sudo pi-shrink raspberry-pi-image.img
To flash the image open the raspberry pi image flasher:
- Select the type of Raspberry Pi
- Select the image you just created
- Select the SD card to write too
