Skip to content

Instantly share code, notes, and snippets.

@sirdlx
Created November 17, 2014 05:26
Show Gist options
  • Save sirdlx/f19e42e9baa37d46b3bf to your computer and use it in GitHub Desktop.
Save sirdlx/f19e42e9baa37d46b3bf to your computer and use it in GitHub Desktop.
STARTUP_VERSION=1
PARTITION_MARK=/var/startup.partition.$STARTUP_VERSION
RESIZE_MARK=/var/startup.resize.$STARTUP_VERSION
# Repartition the disk to full size
function partition() {
start_sector=$(sudo fdisk -l | grep ^/dev/sda1 | awk -F" " '{ print $3 }')
cat <<EOF | sudo fdisk -c -u /dev/sda
d
n
p
1
$start_sector
w
EOF
# We've made the changes to the partition table, they haven't taken effect; we need to reboot.
touch $PARTITION_MARK
sudo reboot
exit
}
# Resize the filesystem
function resize() {
resize2fs /dev/sda1
touch $RESIZE_MARK
}
if [ ! -f $PARTITION_MARK ]; then
partition
fi
if [ ! -f $RESIZE_MARK ]; then
resize
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment