X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=fai%2Fconfig%2Ffiles%2Fetc%2Finit.d%2Fexpand-root%2FGCE;fp=fai%2Fconfig%2Ffiles%2Fetc%2Finit.d%2Fexpand-root%2FGCE;h=82480e723ff9d287c6387da2006cb71e0e2f2198;hb=056eb4e90e13b2d8f7cbb8c3b875f35bf0fa207e;hp=0000000000000000000000000000000000000000;hpb=a6f3eaed0a1eebb5c58853fb9faa8bfbec404de3;p=automated-distro-installer diff --git a/fai/config/files/etc/init.d/expand-root/GCE b/fai/config/files/etc/init.d/expand-root/GCE new file mode 100755 index 0000000..82480e7 --- /dev/null +++ b/fai/config/files/etc/init.d/expand-root/GCE @@ -0,0 +1,40 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: expand-root +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Description: Expand the filesystem of the mounted root volume/partition to its maximum possible size +### END INIT INFO + +prog=$(basename $0) +logger="logger -t $prog" + +growpart="growpart" + +hash $growpart 2> /dev/null || { + $logger "$growpart was not found on PATH. Unable to expand size." + exit 1 +} + +root_device_path="/dev/sda" +root_index="1" + +# Growpart can fail if the partition is already resized. +$growpart $root_device_path $root_index || { + $logger "growpart failed. Unable to expand size." +} + +device_path="${root_device_path}${root_index}" +filesystem=$(blkid -s TYPE -o value ${device_path}) + +case $filesystem in + xfs) xfs_growfs / ;; + ext2) resize2fs $device_path ;; + ext3) resize2fs $device_path ;; + ext4) resize2fs $device_path ;; + *) $logger "The filesystem $filesystem was not recognized. Unable to expand size." ;; +esac