0

I am currently creating a very minimal image for the Raspberry Pi 4. And I need the image itself to be as small as possible in order to reduce the time to flash the SD-card.

I do however, want to expand the file-system automatically when the Raspberry Pi 4 first boot.

I just threw this into a bash-script:

#!/bin/bash -x -e
raspi-config nonint do_expand_rootfs
rm -- "$0"
reboot

Running this works, but how to I run this just once when the Pi boots?

1

Yes, there is a quite simple way to do this!

First, place your expand-script in a good folder, like /usr/local/bin/expand.sh, and make it executable with chmod +x /usr/local/bin/expand.sh

Then, edit /boot/config.txt and add the following furthest down:

[expansion]
init=/usr/local/bin/expand.sh

Reboot, and then observe the expanded filesystem with df -h

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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