Skip to content

Commit

Permalink
add expand-root script, this was taken from bootstrap-vz and adjusted
Browse files Browse the repository at this point in the history
to the devices in GCE
  • Loading branch information
Thomas Lange committed Nov 4, 2016
1 parent 2c686fa commit a7bf366
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/simple/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
3 changes: 3 additions & 0 deletions examples/simple/scripts/CLOUD/99-cleanup
@@ -1,5 +1,8 @@
#! /bin/bash

fcopy /etc/init.d/expand-root
$ROOTCMD insserv --default expand-root

sed -i "s/PermitRootLogin yes/PermitRootLogin without-password/" $target/etc/ssh/sshd_config
ainsl /etc/ssh/sshd_config 'ClientAliveInterval 120'

Expand Down

0 comments on commit a7bf366

Please sign in to comment.