Add ability to grow root partition + filesystem
This commit is contained in:
16
files/grow-root
Normal file
16
files/grow-root
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/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
|
9
files/grow-root.service
Normal file
9
files/grow-root.service
Normal file
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Grows the root partition and filesystem to match disk size
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/sbin/grow-root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in New Issue
Block a user