How does one prevent Stretch from expanding the file system at boot time ? When you flash the new Stretch image (september 2017) on the SD card and boot the first time, it auto expands the file system on the whole SD card. Preventing this used to be possible under Jessie by removing the init= in cmdline.txt; there is no longer this option.

So how does one prevent this auto expand -- a 32GB card takes 40 minutes to copy to img format. I would love to keep the image to 6 or 8GB which is plenty for me, this would radically cut the time needed to backup and clone SD cards.

  • I don't see a question here.
    – Brick
    Nov 11, 2017 at 22:20
  • Clarified the issue I was having.
    – jflamy
    Nov 12, 2017 at 23:15

1 Answer 1


Answering myself. Easiest way is to use the pishrink.sh script, and pass it -s as parameter to prevent autoexpand. In short:

  • create an image file (e.g. using win32diskimager on a win10 laptop, or dd on linux)
  • use pishrink.sh -s to perform the shrinking (on a win10 laptop, install virtualbox and run a lubuntu image with a shared folder -- see osboxes.org to get a virtual machine)
  • I edited the script to set the minsize I wanted (8GB or less is fine for me): at line 149 of the script I just added


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.