2013-07-07 14:58:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
### BEGIN INIT INFO
|
2013-11-21 16:58:21 +01:00
|
|
|
# Provides: expand-root
|
2013-07-07 14:58:03 +02:00
|
|
|
# Required-Start:
|
|
|
|
# Required-Stop:
|
|
|
|
# Should-Start:
|
|
|
|
# Should-Stop:
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop:
|
2013-11-21 16:58:21 +01:00
|
|
|
# Description: Expand the filesystem of the mounted root volume/partition to its maximum possible size
|
2013-07-07 14:58:03 +02:00
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
prog=$(basename $0)
|
|
|
|
logger="logger -t $prog"
|
|
|
|
|
2016-01-12 18:33:22 +00:00
|
|
|
hash growpart 2> /dev/null || {
|
2015-06-30 15:14:41 -03:00
|
|
|
$logger "growpart was not found on PATH. Unable to expand size."
|
2016-01-12 18:33:18 +00:00
|
|
|
exit 1
|
2015-06-30 15:14:41 -03:00
|
|
|
}
|
2013-07-07 14:58:03 +02:00
|
|
|
|
2016-01-12 18:33:41 +00:00
|
|
|
root_device_path="/dev/xvda"
|
2015-06-30 15:14:41 -03:00
|
|
|
root_index="0"
|
|
|
|
|
2016-01-12 18:33:41 +00:00
|
|
|
growpart $root_device_path $root_index || {
|
2015-06-30 15:14:41 -03:00
|
|
|
$logger "growpart failed. Unable to expand size."
|
2016-01-12 18:33:18 +00:00
|
|
|
exit 1
|
2015-06-30 15:14:41 -03:00
|
|
|
}
|
|
|
|
|
2016-01-12 18:33:41 +00:00
|
|
|
device_path="${root_device_path}${root_index}"
|
2015-06-24 12:41:06 -07:00
|
|
|
filesystem=$(blkid -s TYPE -o value ${device_path})
|
2013-07-07 14:58:03 +02:00
|
|
|
|
|
|
|
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
|