Skip to content

Instantly share code, notes, and snippets.

@patchedsoul
Created February 7, 2020 11:54
Show Gist options
  • Select an option

  • Save patchedsoul/50463488a9c5979872d914dbe7867e52 to your computer and use it in GitHub Desktop.

Select an option

Save patchedsoul/50463488a9c5979872d914dbe7867e52 to your computer and use it in GitHub Desktop.
postmarketos_rootfs_resizer.sh
#!/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