Skip to content

Expands a Raspberry Pi microSD image to match the disk size, the inverse of PiShrink

License

Notifications You must be signed in to change notification settings

tiny-pilot/pi-expand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-expand

License CircleCI

Overview

Expands a Raspberry Pi microSD image to match the disk size.

Why?

The standard Raspberry Pi microSD image initially writes to a small portion of the microSD. On the microSD's first boot, it expands the filesystem to occupy the full size of the microSD image. If the user cuts power to their device during the expansion, it will corrupt the filesystem, leaving the device in an unbootable state.

If you know the target microSD size in advance, you can perform the expansion step at image creation time, reducing your image's time to first boot and reducing the risk of filesystem corruption.

Usage

Expand the standard Raspberry Pi OS Lite image to 29800 MiB to fit a 32 GB microSD card:

sudo ./pi-expand \
  --in 2023-02-21-raspios-bullseye-armhf-lite.img \
  --out 2023-02-21-raspios-bullseye-armhf-lite-expanded.img \
  --size 29800

Tips

  • Balena Etcher recognizes unused space in a disk image and can optimize it out of disk writes. Writing an expanded image with Balena Etcher takes approximately the same time as writing a non-expanded image.
    • Note that Balena's optimization fails if the image is compressed.
  • If you're transferring the image across the network, gzipping it first will reduce file size by an order of magnitude.

About

Expands a Raspberry Pi microSD image to match the disk size, the inverse of PiShrink

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages