17 lines
389 B
Plaintext
17 lines
389 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
dev="$(findmnt -nfvo SOURCE -- "/")"
|
||
|
|
||
|
# If it's a partition, expand that first using growpart.
|
||
|
if [ "$(lsblk -ndo TYPE -- "$dev")" = part ]; then
|
||
|
disk="$(lsblk -ndpo PKNAME -- "$dev")"
|
||
|
partnum="${dev##*[!0-9]}"
|
||
|
growpart "$disk" "$partnum" || { [ $? -ne 1 ] && exit 1; }
|
||
|
fi
|
||
|
|
||
|
# Inform kernel of new partition
|
||
|
partprobe
|
||
|
|
||
|
# Expand the filesystem.
|
||
|
resize2fs -- "$dev" || exit 1
|