From 382b3d602d353c79c1aa20800fcbce9e67f35d91 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 21 Jul 2015 21:41:10 -0400 Subject: [PATCH] gh-10: add script to grow root fs Uses growpart from cloud-utils and supports ext4 and xfs --- base/etc/one-context.d/07-grow-rootfs | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 base/etc/one-context.d/07-grow-rootfs diff --git a/base/etc/one-context.d/07-grow-rootfs b/base/etc/one-context.d/07-grow-rootfs new file mode 100755 index 0000000..2874a99 --- /dev/null +++ b/base/etc/one-context.d/07-grow-rootfs @@ -0,0 +1,28 @@ +#!/bin/bash + +MOUNT_LINE=$(cat /etc/mtab | grep ' / ' | grep -v '^rootfs') + +DEVICE=$(echo "$MOUNT_LINE" | cut -d' ' -f1) +FSTYPE=$(echo "$MOUNT_LINE" | cut -d' ' -f3) + +DISK=$(echo "$DEVICE" | sed 's/.$//') +PARTITION=$(echo "$DEVICE" | sed "s|^$DISK||") + +if [ -n $DEBUG ]; then + echo DEVICE: $DEVICE + echo FSTYPE: $FSTYPE + echo DISK: $DISK + echo PARTITION: $PARTITION +fi + +growpart "$DISK" "$PARTITION" + +case "$FSTYPE" in +ext2|ext3|ext4) + resize2fs "$DEVICE" + ;; +xfs) + xfs_growfs / + ;; +esac +