From 0f3b4985c31335a82d4d064e5f9641546cb98e2d Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Sat, 1 Dec 2018 18:46:46 -0500 Subject: [PATCH] Correct size_margin for rootfs resizes See https://github.com/QubesOS/qubes-core-agent-linux/pull/146#discussion_r238080117 for details; but tl;dr: * Journal size is 64M * Inode table is 256 bytes * 643376 inodes allocated = ~157M * Reserved GDT blocks take up 1024 blocks * 4096 byte block size = 4M * Fixed-size parts of the filesystem probably take up another MB or two These actually adds up to more than the 222M number used in this commit. But it seems _about_ right, so just Ship It(tm). --- init/resize-rootfs-if-needed.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/init/resize-rootfs-if-needed.sh b/init/resize-rootfs-if-needed.sh index c94513c..77207cf 100755 --- a/init/resize-rootfs-if-needed.sh +++ b/init/resize-rootfs-if-needed.sh @@ -14,7 +14,9 @@ fi sysfs_xvda="/sys/class/block/xvda" # if root filesystem use already (almost) the whole dis -size_margin=$(( 250 * 1024 * 2 )) +# 203M for BIOS and /boot data, 222 for ext4 filesystem overhead +# See QubesOS/qubes-core-agent-linux#146 for more details +size_margin=$(((222 + 203) * 2 * 1024)) rootfs_size=$(df --block-size=512 --output=size / | tail -n 1 | tr -d ' ') if [ $(cat $sysfs_xvda/size) -lt \ $(( size_margin + rootfs_size )) ]; then