Created
February 7, 2020 11:54
-
-
Save patchedsoul/50463488a9c5979872d914dbe7867e52 to your computer and use it in GitHub Desktop.
postmarketos_rootfs_resizer.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| set -e | |
| if [ "$(id -u)" -ne "0" ]; then | |
| echo "This script requires root." | |
| exit 1 | |
| fi | |
| set -x | |
| DEVICE="/dev/mmcblk0" | |
| PART="3" | |
| resize() { | |
| start=$(fdisk -l ${DEVICE} | grep ${DEVICE}p${PART} | sed 's/*//' | awk '{print $2}') | |
| echo $start | |
| set +e | |
| fdisk ${DEVICE} <<EOF | |
| p | |
| d | |
| 3 | |
| n | |
| p | |
| 3 | |
| $start | |
| a | |
| 3 | |
| w | |
| EOF | |
| set -e | |
| partx -u ${DEVICE} | |
| resize2fs ${DEVICE}p${PART} | |
| } | |
| resize | |
| echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment