use smarter logic for shrinking the btrfs

size is only approximate and depending on how big a number it is the
512M buffer may not be enough
This commit is contained in:
Harald Sitter
2024-11-06 15:31:28 +01:00
parent 40b3f76a17
commit ad734333a6

View File

@@ -10,6 +10,7 @@
import json
import os
import math
import subprocess
from subprocess import check_output
@@ -21,8 +22,8 @@ size = 0
for block_group in df:
size += block_group["total"]
# Give 512MiB of buffer space. We'll shrink from there in smaller steps.
size += 512 * 1024 * 1024
# Give 10% buffer space. We'll shrink from there in smaller steps.
size = max(512 * 1024 * 1024, math.ceil(size * 1.1))
subprocess.run(["btrfs", "filesystem", "resize", str(size), "."], check=True)