#!/bin/bash
if [ -z "${1}" ] || [ -z "${2}" ]; then
	echo "Usage: ${0} imagefile sizeinMBtogrow"
else
	echo "Verify ext fs..."
	e2fsck -yf "${1}" > /dev/null
	echo "Expanding image file by ${2}MB..."
	dd if=/dev/zero "of=${1}" bs=1M "count=${2}" oflag=append conv=notrunc
	echo "Resize ext fs..."
	resize2fs "${1}" > /dev/null
fi
