Skip to content

Commit 973f4af

Browse files
authored
fix(lvm): align offset to PE size to avoid LV allocation failure (#3603)
1 parent 4d0a6ce commit 973f4af

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

archinstall/lib/disk/filesystem.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import math
34
import time
45
from pathlib import Path
56

@@ -195,7 +196,15 @@ def _setup_lvm(
195196
desired_size = sum([vol.length for vol in vg.volumes], Size(0, Unit.B, SectorSize.default()))
196197

197198
delta = desired_size - avail_size
198-
max_vol_offset = delta.convert(Unit.B)
199+
delta_bytes = delta.convert(Unit.B)
200+
201+
# Round the offset up to the next physical extent (PE, 4 MiB by default)
202+
# to ensure lvcreate`s internal rounding doesn`t consume space reserved
203+
# for subsequent logical volumes.
204+
pe_bytes = Size(4, Unit.MiB, SectorSize.default()).convert(Unit.B)
205+
pe_count = math.ceil(delta_bytes.value / pe_bytes.value)
206+
rounded_offset = pe_count * pe_bytes.value
207+
max_vol_offset = Size(rounded_offset, Unit.B, SectorSize.default())
199208

200209
max_vol = max(vg.volumes, key=lambda x: x.length)
201210

0 commit comments

Comments
 (0)