update to 5.4
[automated-distro-installer] / fai / config / files / etc / init.d / expand-root / GCE
1 #!/bin/bash
2 ### BEGIN INIT INFO
3 # Provides: expand-root
4 # Required-Start:
5 # Required-Stop:
6 # Should-Start:
7 # Should-Stop:
8 # Default-Start: 2 3 4 5
9 # Default-Stop:
10 # Description: Expand the filesystem of the mounted root volume/partition to its maximum possible size
11 ### END INIT INFO
12
13 prog=$(basename $0)
14 logger="logger -t $prog"
15
16 growpart="growpart"
17
18 hash $growpart 2> /dev/null || {
19 $logger "$growpart was not found on PATH. Unable to expand size."
20 exit 1
21 }
22
23 root_device_path="/dev/sda"
24 root_index="1"
25
26 # Growpart can fail if the partition is already resized.
27 $growpart $root_device_path $root_index || {
28 $logger "growpart failed. Unable to expand size."
29 }
30
31 device_path="${root_device_path}${root_index}"
32 filesystem=$(blkid -s TYPE -o value ${device_path})
33
34 case $filesystem in
35 xfs) xfs_growfs / ;;
36 ext2) resize2fs $device_path ;;
37 ext3) resize2fs $device_path ;;
38 ext4) resize2fs $device_path ;;
39 *) $logger "The filesystem $filesystem was not recognized. Unable to expand size." ;;
40 esac