fully balance before shrink

when looking at a heatmap of the partition it's still not quite ideal,
when I manually shrink it I get a better block layout, so let's try to
balance the blocks before shrinking. if nothing else it should mean less
relocation during shrinking
This commit is contained in:
Harald Sitter
2024-11-06 18:08:16 +01:00
parent 75bc73d176
commit 61fb76f19d
2 changed files with 8 additions and 0 deletions

View File

@@ -57,6 +57,9 @@ btrfs filesystem usage .
duperemove -dr . > /dev/null
btrfs subvolume sync .
btrfs filesystem sync .
btrfs balance start --full-balance --enqueue .
btrfs subvolume sync .
btrfs filesystem sync .
## And to finish things off we shrink the filesystem to the minimum size.
$OUTPUT_DIR/btrfs-shrink.py
## Sync changes to disk.

View File

@@ -8,6 +8,11 @@
# portion but leave a bit of a buffer behind. Then we keep resizing until the
# resize starts failing.
# TODO we can produce an even more squeezed image by deriving a complete partition
# from the initial partition. https://btrfs.readthedocs.io/en/latest/Seeding-device.html
# It essentially transfers the data from the seed device with nary a fragmentation.
# Requires juggling loop devices though, and the gains are in the sub 500MiB range.
import json
import os
import math