Create a custom Raspberry pi image
Step 1: Prepare your current Pi
- Boot your Raspberry Pi using SD card with a default base image of your choice.
- Run system updates:
sudo apt update && sudo apt upgrade -y - Clean up temporary files:
sudo apt autoremove && sudo apt autoclean - Setup the Pi exactly the way you want you new image to be i.e.
- Install all the software you need
- Setup any new configurations you want
Step 2: Create the image
- Shut down the Pi and remove the SD card
- Insert it into a computer with a card reader
- Use imaging software to create a backup:
- Windows: Win32DiskImager or Raspberry Pi Imager (Not tested. Not a Windows user. Sorry!)
- Linux/macOS:
ddcommand
Example with dd:
- Find the disk path of your SD card using
lsblkordf -h - Run the following replacing
/dev/sdXwith the path found using above.
sudo dd if=/dev/sdX of=my-custom-pi-image.img bs=4M status=progress
Step 3: Shrink the image (optional)
- Use
PiShrinkto reduce image size:wget https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh - Make it executable:
chmod +x pishrink.sh - Shrink:
sudo ./pishrink.sh my-custom-pi-image.img