asb / raspi-config

Configuration tool for the Raspberry Pi. Now maintained at https://github.com/RPi-Distro/raspi-config
Other
263 stars 328 forks source link

Detect whether filesystem has been expanded #64

Open wtluke opened 8 years ago

wtluke commented 8 years ago

Hi,

On my Pi setup/installation script, I use raspi-config --expand-rootfs but would like to tell whether or not the filesystem has been expanded, so that it doesn't repeatedly try to do it (when it has already been done).

Trawled through github without luck. I could create a temp file when it's been done, before rebooting, but wondered if anyone could help with something more comprehensive using df

Ideas welcome

Thanks

maditnerd commented 8 years ago

I don't know if it is the correct way to do this but here is a script I made to check if a SD card is resized. If someone has a better method, i'm interested :-)

# Check if there is free space on the SD card
unusedDisk=$(parted /dev/mmcblk0 unit GB print free | grep 'Free Space' | tail -n1 | awk '{print $3}')
if [[ ! $unusedDisk == "0.00GB" ]];then
        raspi-config --expand-rootfs #If not run raspi-config unattended
else
        echo "SD card already resized"
fi