Skip to content

Use PiShrink in macOS with Apple Silicon M1/M2/M3... #326

@xavi-burgos99

Description

@xavi-burgos99

Use PiShrink on Apple Silicon macOS (via Docker Desktop)

Prerequisite

  • Docker Desktop must be installed and running.

Install PiShrink with Docker

  1. Enter your PiShrink directory
cd ~/PiShrink/

Note

I recommend using this directory for permissions and mounting simplicity.

  1. Build the Docker image
docker build -t pishrink .
  1. Add a pishrink shortcut to your shell
sudo nano ~/.zshrc

Add this at the end:

# pishrink shortcut
pishrink() {
  docker run --rm --platform linux/arm64 --privileged \
    -v "$PWD":/workdir \
    pishrink "$@"
}
  1. Reload your shell
source ~/.zshrc

Shrink your SD-Card Image

  1. List external physical disks to identify your SD-card (e.g. /dev/rdisk4)
diskutil list external physical
  1. Unmount the SD-card
diskutil unmountDisk /dev/rdisk4

Note

Replace /dev/rdisk4 with the location of your disk.

  1. Create a raw image of the SD-card
sudo dd if=/dev/rdisk4 bs=4m status=progress of="raspi.img"

Warning

I recommend to copy the image to the internal storage of the mac.

Tip

Using rdisk instead of disk, and bs=4m to copy the image fastly. In my case, 64GB in ~25 minutes.

  1. Eject the SD-card
sync && diskutil eject /dev/rdisk4
  1. Adjust permissions on the image
sudo chmod 777 raspi.img
  1. Run PiShrink to compress
pishrink -zv raspi.img raspi.shrink.img

Feel free to open a discussion if you have suggestions or issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions