Skip to content

Instantly share code, notes, and snippets.

@rany2
Created October 27, 2022 21:14
Show Gist options
  • Select an option

  • Save rany2/38a655bf2a377f3b8eb7d50578e0a3b5 to your computer and use it in GitHub Desktop.

Select an option

Save rany2/38a655bf2a377f3b8eb7d50578e0a3b5 to your computer and use it in GitHub Desktop.
#!/bin/sh
# requires parted, losetup, and resize2fs
BOOT="$(sed -n -e "\|\s/boot\s.*$|{s///p;q}" /etc/mtab)"
DISK="${BOOT%%[0-9]*}"
PART="$((${BOOT##*[^0-9]}+1))"
printf "fix\n" | parted ---pretend-input-tty ${DISK} print
parted ${DISK} resizepart ${PART} 100%
ROOT="${DISK}${PART}"
LOOP="$(losetup -f)"
losetup ${LOOP} ${ROOT}
resize2fs -f ${LOOP}
losetup -d ${LOOP}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment