Skip to content

Instantly share code, notes, and snippets.

@joshwget
Created April 11, 2016 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshwget/8f7397e4ede9fd1457599daa97ff644d to your computer and use it in GitHub Desktop.
Save joshwget/8f7397e4ede9fd1457599daa97ff644d to your computer and use it in GitHub Desktop.
#!/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