Created
April 11, 2016 20:21
-
-
Save joshwget/8f7397e4ede9fd1457599daa97ff644d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
RESIZE_DEV=/dev/xvda | |
STAMP=/var/log/resizefs.done | |
if [ -e "${STAMP}" ]; then | |
echo FS already resized. | |
exit 0 | |
fi | |
if [ -b "${RESIZE_DEV}" ]; then | |
START=$(fdisk ${RESIZE_DEV} <<EOF | grep -e "^${RESIZE_DEV}1" | awk '{print $2}' | |
p | |
q | |
EOF | |
) | |
fdisk ${RESIZE_DEV} <<EOF | |
d | |
n | |
p | |
1 | |
${START} | |
a | |
w | |
EOF | |
partprobe | |
resize2fs ${RESIZE_DEV}1 || : | |
else | |
echo "Block device expected: ${RESIZE_DEV} is not." | |
exit 1 | |
fi | |
touch $STAMP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment