
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).
29 lines
827 B
Bash
Executable File
29 lines
827 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# Possibly resize root device (partition, filesystem), if underlying device was
|
|
# enlarged.
|
|
|
|
set -e
|
|
|
|
# if underlying root device is read-only, don't do anything
|
|
if [ "$(blockdev --getro /dev/xvda)" -eq "1" ]; then
|
|
echo "xvda is read-only, not resizing" >&2
|
|
exit 0
|
|
fi
|
|
|
|
sysfs_xvda="/sys/class/block/xvda"
|
|
|
|
# if root filesystem use already (almost) the whole dis
|
|
# 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
|
|
echo "root filesystem already at $rootfs_size blocks" >&2
|
|
exit 0
|
|
fi
|
|
|
|
# resize needed, do it
|
|
/usr/lib/qubes/resize-rootfs
|