#!/bin/sh set -e # No resizing with less than 10k unused blocks BLOCKS_FREE=$(/usr/bin/awk '/sda$/ {blocks = $3} /sda\d/ {blocks -= $3} END {print blocks}' /proc/partitions) [ ${BLOCKS_FREE} -lt 10240 ] && exit 0 # Resize physical partition # Force busybox fdisk as util-linux fdisk breaks subsequent partx command cat <