diff --git a/init/resize-rootfs-if-needed.sh b/init/resize-rootfs-if-needed.sh index 1c01bb1..c3d21cb 100755 --- a/init/resize-rootfs-if-needed.sh +++ b/init/resize-rootfs-if-needed.sh @@ -11,14 +11,16 @@ if [ "$(blockdev --getro /dev/xvda)" -eq "1" ]; then exit 0 fi -sysfs_root_dev="/sys/dev/block/$(mountpoint -d /)" sysfs_xvda="/sys/class/block/xvda" # if root filesystem use already (almost) the whole dis non_rootfs_data=$(( 250 * 1024 * 2 )) +rootfs_size=$(df --output=size / | tail -n 1) +# convert to 512-byte blocks +rootfs_size=$(( rootfs_size * 2 )) if [ "$(cat "$sysfs_xvda/size")" -lt \ - $(( non_rootfs_data + $(cat "$sysfs_root_dev/size") )) ]; then - echo "root filesystem already at the right size" >&2 + $(( non_rootfs_data + rootfs_size )) ]; then + echo "root filesystem already at $rootfs_size blocks" >&2 exit 0 fi