23 lines
677 B
Bash
23 lines
677 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -xeu
|
||
|
|
||
|
if [[ ${EUID} -ne 0 || ${UID} -ne 0 ]]; then
|
||
|
>&2 echo "$0: error: please run this script as root"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
ROOT_DEVICE=$(mount | grep 'on / ' | awk '{print $1}')
|
||
|
ROOT_PARTITION="${ROOT_DEVICE: -1}"
|
||
|
if [[ "${ROOT_DEVICE}" =~ "mmcblk" || "${ROOT_DEVICE}" =~ "nvme" ]]; then
|
||
|
PARENT_ROOT_DEVICE=$(echo "${ROOT_DEVICE}" | rev | sed -r 's/^.{2}//' | rev)
|
||
|
elif [[ "${ROOT_DEVICE}" =~ "vd" || "${ROOT_DEVICE}" =~ "sd" ]]; then
|
||
|
PARENT_ROOT_DEVICE=$(echo "${ROOT_DEVICE}" | rev | sed -r 's/^.{1}//' | rev)
|
||
|
else
|
||
|
>&2 echo "$0: device type unsupported"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
growpart "${PARENT_ROOT_DEVICE}" "${ROOT_PARTITION}"
|
||
|
xfs_growfs -d /
|