diff options
author | Jonathan Bauer | 2020-05-13 11:04:02 +0200 |
---|---|---|
committer | Jonathan Bauer | 2020-05-13 11:04:02 +0200 |
commit | 1130873aa55c9b0a7e5af48edc44bd6c6fd1f888 (patch) | |
tree | 0fcfa186cd631d8d36611b3d4bc509fd38841d51 /modules.d/slx-dmsetup/scripts/grow-rootfs.sh | |
parent | Merge branch 'centos8' into downloader (diff) | |
download | systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.gz systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.tar.xz systemd-init-1130873aa55c9b0a7e5af48edc44bd6c6fd1f888.zip |
restructure repo
* remove packager
* move everything from builder/* back to root
Diffstat (limited to 'modules.d/slx-dmsetup/scripts/grow-rootfs.sh')
-rw-r--r-- | modules.d/slx-dmsetup/scripts/grow-rootfs.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/modules.d/slx-dmsetup/scripts/grow-rootfs.sh b/modules.d/slx-dmsetup/scripts/grow-rootfs.sh new file mode 100644 index 00000000..e2603835 --- /dev/null +++ b/modules.d/slx-dmsetup/scripts/grow-rootfs.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# This tried to call growfs helpers (xfs_growfs, resize2fs, ...) to resize +# the root filesystem mounted on $NEWROOT to the maximum size of the backing +# disk partition (done by dmsetup-slx-device). + +. /etc/openslx + +declare -Ag growfs_helpers growfs_targets growfs_opts +# xfs +growfs_helpers[xfs]="xfs_growfs" +growfs_targets[xfs]="$NEWROOT" +growfs_opts[xfs]="-d" +# ext4 +growfs_helpers[ext4]="resize2fs" +growfs_targets[ext4]="$SLX_DNBD3_DEVICE_COW" +growfs_opts[ext4]="" + +resize_rootfs() { + # First let's check what filesystem it is + local fstype="$(blkid "$SLX_DNBD3_DEVICE_COW" | grep -oE 'TYPE=\S+')" + if [ -z "$fstype" ]; then + echo "Failed to detect filesystem on '$SLX_DNBD3_DEVICE_COW' - ignoring." + return 1 + fi + fstype="${fstype#TYPE=}" + fstype="${fstype//\"/}" + if [ ! "${growfs_helpers[${fstype}]+set}" ]; then + echo "'$fstype' not supported - ignoring." + return 1 + fi + if ! hash "${growfs_helpers[${fstype}]}" &> /dev/null; then + echo "'$fstype' is supported, but cannot find helper binary - ignoring." + return 1 + fi + if ! "${growfs_helpers[${fstype}]}" ${growfs_opts[$fstype]} "${growfs_targets[$fstype]}"; then + echo "Failed to run '${growfs_helpers[${fstype}]}' on '${growfs_targets[$fstype]}'." + return 1 + fi + return 0 +} &> /run/openslx/rootfs-grow.log + +[ -b "$SLX_DNBD3_DEVICE_COW" ] && resize_rootfs +# non-critical, so always fake success +true |