Commit Graph

13 Commits

Author SHA1 Message Date
AJ Jordan
593724c05b
Use dumpe2fs for filesystem size calculations
The previous approach used `df` to get usable space and then added a
fixed size to that number in order to account for filesystem
overhead. However, at some point that stopped working for me. It
appears that ext4 filesystem overhead can vary over time or because of
other factors. (Certainly now that I think about it the old code would
only work well for people with the exact same filesystem size as me.)

So the new approach is to just completely ignore what `df` tells us
and instead go directly to the source: the filesystem's internal
notion of exactly how much space it takes up. We use `dumpe2fs` to
retrieve this information and calculate the on-disk size dynamically
from that. Then we add the space that boot data takes up (unchanged),
and we add 5MB padding because when I tested this it didn't quite add
up otherwise. https://unix.stackexchange.com/a/13551/29146 suggests
that this unaccounted-for data may be e.g. additional copies of the
superblock.
2019-02-07 16:04:11 -05:00
Marek Marczykowski-Górecki
d92204e094
Merge remote-tracking branch 'origin/pr/145'
* origin/pr/145:
  Rephrase comment
2018-12-02 16:10:20 +01:00
AJ Jordan
235d44e632
Add quotes to placate ShellCheck 2018-12-01 19:30:07 -05:00
AJ Jordan
0f3b4985c3
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).
2018-12-01 18:46:46 -05:00
AJ Jordan
c05310f61c
Revert "Fix root volume size comparison"
This reverts commit 8000e76d43, because
as @marmarek pointed out, the original was correct and I totally
misread. The check in question is checking whether to _abort_, not
whether to continue. So we want to check if the block device size is
_less_ than the filesystem + margin, not more.

Reopens QubesOS/qubes-issues#4553
2018-12-01 16:19:56 -05:00
AJ Jordan
737a65e5e7
Rename variable to be more clear 2018-12-01 00:01:04 -05:00
AJ Jordan
ce78625bec
Remove weird spaces from script output 2018-12-01 00:01:02 -05:00
AJ Jordan
8000e76d43
Fix root volume size comparison
Fixes QubesOS/qubes-issues#4553
2018-12-01 00:00:57 -05:00
AJ Jordan
98a6b60a49
Remove unnecessary quotes 2018-11-30 23:56:13 -05:00
AJ Jordan
bc6c729a82
Simplify block number calculation 2018-11-30 23:46:09 -05:00
AJ Jordan
b85c1cec75
Rephrase comment 2018-11-28 23:25:09 -05:00
Marek Marczykowski-Górecki
581d9c12ed
Fix detection of root device resize
If xvda is not partitioned, checking size of device mounted as root dev
doesn't detect xvda resize - it will have the new size, while the fs on
it not. Change to checking actual filesystem size.

Also, improve log message to include the size.

Fixes QubesOS/qubes-issues#4274
2018-09-04 18:12:07 +02:00
Marek Marczykowski-Górecki
1ed6e614ab
Resize root filesystem at VM startup if needed
Check if root device was enlarged while domain was powered off and
resize the filesystem in such a case.

QubesOS/qubes-issues#3173
QubesOS/qubes-issues#3143
2017-10-18 21:02:15 +02:00