pvsqueeze.sh update

This commit is contained in:
Chris Hammer 2025-03-20 15:26:02 -04:00
parent a4a9c2fa89
commit 212ace2d6d

View File

@ -1,10 +1,14 @@
#!/bin/bash
#
# pvsqueeze - Squeeze PEs into free holes
# pvsqueeze - Squeeze linear extents into free holes
#
# This script iteratively moves linear (allocated to LV) PEs to fill in free
# holes found in a PV segement map. The end result is that all free PEs are
# at the end of the PV. Use this script as required in anger!
# This script iteratively moves linear (allocated to LV) extents to fill in
# free holes found in a PV segment map. The end result is that all free
# extents are at the end of the PV. Use this script in anger as required!
#
# The script outputs the PV segment map before moving anything, then iterates
# stuffing extents in each free hole until there are no more except for the
# last one, and finally outputs the PV segment map again showing the changes.
#
# Usage
@ -51,6 +55,7 @@ while true; do
[[ $free_start -gt $move_start ]] && break
# Move last linear PEs to the free segment
[[ $free_size -gt $move_size ]] && free_size=$move_size
from_range="$pvdev:$((move_start+move_size-free_size))-$((move_start+move_size-1))"
to_range="$pvdev:$((free_start))-$((free_start+free_size))"
echo "Moving $from_range to $to_range..."