Compare commits

...

3 Commits

3 changed files with 21 additions and 2 deletions

View File

@ -4,7 +4,9 @@ set -x
# The script that expands root partition
[ -d /usr/local/bin ] || mkdir --verbose /usr/local/bin
curl 'https://git.resf.org/thefossguy/sbc-images/raw/branch/rocky-generic/scripts/expand-rootfs.sh' --output /usr/local/bin/expand-rootfs.sh || exit 1
curl 'https://git.resf.org/thefossguy/sbc-images/raw/branch/rocky-generic/scripts/expand-rootfs.service' --output /etc/systemd/system/expand-rootfs.service || exit 1
[ -f /usr/local/bin/expand-rootfs.sh ] && \
chmod --verbose +x /usr/local/bin/expand-rootfs.sh
systemctl enable expand-rootfs.service
%end

View File

@ -0,0 +1,10 @@
[Unit]
Description=Expand root filesystem
[Service]
ExecStart=$(command -v bash) /usr/local/bin/expand-rootfs.sh
Type=oneshot
User=root
[Install]
WantedBy=default.target

View File

@ -18,5 +18,12 @@ else
exit 1
fi
growpart "${PARENT_ROOT_DEVICE}" "${ROOT_PARTITION}"
resize2fs "${ROOT_DEVICE}"
growpart "${PARENT_ROOT_DEVICE}" "${ROOT_PARTITION}" && GP_OK='true'
resize2fs "${ROOT_DEVICE}" && RESIZE_OK='true'
if [[ "${GP_OK}" == 'true' && "${RESIZE_OK}" == 'true' ]]; then
systemctl disable expand-rootfs.service
rm /etc/systemd/system/expand-rootfs.service
systemctl daemon-reload
rm /usr/local/bin/expand-rootfs.sh
fi