Skip to content

Instantly share code, notes, and snippets.

@amitkhare
Created August 14, 2023 14:20
Show Gist options
  • Save amitkhare/6c5612b52e0f87ab8d77dc29d78e8878 to your computer and use it in GitHub Desktop.
Save amitkhare/6c5612b52e0f87ab8d77dc29d78e8878 to your computer and use it in GitHub Desktop.
Expand DietPi SD CARD
#!/bin/bash
#Stop Services
/DietPi/dietpi/dietpi-services stop
#Resize partition
cat << _EOF_ | fdisk /dev/mmcblk0
p
d
2
n
p
2
$(parted /dev/mmcblk0 -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print $2 }')
p
w
_EOF_
#!/bin/bash
# Stop Services
/DietPi/dietpi/dietpi-services stop
# Resize Filesystem to new partition size
resize2fs /dev/mmcblk0p2
# Start services
/DietPi/dietpi/dietpi-services start
@amitkhare
Copy link
Author

Step 01 [Resize Partition]

$ chmod +x expand-dietpi-step-1.sh
$ ./expand-dietpi-step-1.sh

Step 02

$ reboot

Step 03 [Resize ext4 filesystem]

$ chmod +x expand-dietpi-step-2.sh
$ ./expand-dietpi-step-2.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment