filesystem: ensure bootfs at aligned size
Certain disk sizes could trigger unaligned bootfs size. This can result in the next partition overlapping into the bootfs partition. LP: #1992541
This commit is contained in:
parent
c2e1daa35c
commit
62ed92505a
|
@ -158,9 +158,11 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
|||
self.create_partition(device=gap.device, gap=gap, spec=spec)
|
||||
|
||||
def guided_lvm(self, gap, lvm_options=None):
|
||||
gap_boot, gap_rest = gap.split(sizes.get_bootfs_size(gap.size))
|
||||
spec = dict(fstype="ext4", mount='/boot')
|
||||
device = gap.device
|
||||
part_align = device.alignment_data().part_align
|
||||
bootfs_size = align_up(sizes.get_bootfs_size(gap.size), part_align)
|
||||
gap_boot, gap_rest = gap.split(bootfs_size)
|
||||
spec = dict(fstype="ext4", mount='/boot')
|
||||
self.create_partition(device, gap_boot, spec)
|
||||
part = self.create_partition(device, gap_rest, dict(fstype=None))
|
||||
|
||||
|
|
|
@ -423,3 +423,36 @@ class TestGuidedV2(IsolatedAsyncioTestCase):
|
|||
self.assertFalse(resp.need_root)
|
||||
self.assertFalse(resp.need_boot)
|
||||
self.assertEqual(0, len(guided_get_resp.possible))
|
||||
|
||||
@parameterized.expand([
|
||||
[10], [20], [25], [30], [50], [100], [250],
|
||||
[1000], [1024],
|
||||
])
|
||||
async def test_lvm_20G_bad_offset(self, disk_size):
|
||||
disk_size = disk_size << 30
|
||||
self._setup(Bootloader.BIOS, 'gpt', size=disk_size)
|
||||
|
||||
guided_get_resp = await self.fsc.v2_guided_GET()
|
||||
|
||||
reformat = guided_get_resp.possible.pop(0)
|
||||
self.assertTrue(isinstance(reformat, GuidedStorageTargetReformat))
|
||||
|
||||
data = GuidedChoiceV2(target=reformat, use_lvm=True)
|
||||
|
||||
expected_config = copy.copy(data)
|
||||
resp = await self.fsc.v2_guided_POST(data=data)
|
||||
self.assertEqual(expected_config, resp.configured)
|
||||
|
||||
resp = await self.fsc.v2_GET()
|
||||
parts = resp.disks[0].partitions
|
||||
|
||||
for p in parts:
|
||||
self.assertEqual(0, p.offset % (1 << 20), p)
|
||||
self.assertEqual(0, p.size % (1 << 20), p)
|
||||
|
||||
for i in range(len(parts) - 1):
|
||||
self.assertEqual(
|
||||
parts[i + 1].offset, parts[i].offset + parts[i].size)
|
||||
self.assertEqual(
|
||||
disk_size - (1 << 20), parts[-1].offset + parts[-1].size,
|
||||
disk_size)
|
||||
|
|
Loading…
Reference in New Issue