bootstrap-vz/bootstrapvz/common/assets/init.d/expand-root
Jonh Wendell c477c32e4a EC2: Added growpart script
This is an attempt to fix issue #237

The script "growpart" was added as an asset, because
Debian's Jessie version (inside cloud-utils) package is
outdated and buggy.

Then "expand-root" init script was modified to call growpart
before calling resize2fs. In fact, calling resize2fs without
resizing the partition first is useless.

The task was named 'AddWorkaroundGrowpart' because it must
go away in the future in favor of using recent stuff in cloud-utils.

Currently even the official images suffer this issue, that makes
the system use only 8 GiB, even if the user chooses a bigger
storage size inside AWS.
2016-01-12 18:46:20 +00:00

37 lines
903 B
Bash

#!/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=$(which growpart) || {
$logger "growpart was not found on PATH. Unable to expand size."
exit 0
}
root_index="0"
$growpart /dev/xvda $root_index || {
$logger "growpart failed. Unable to expand size."
exit 0
}
device_path="/dev/xvda$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