From dd2553723fa7a12b34a3957985e4246cbd36d522 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 5 Oct 2022 18:59:41 +0200 Subject: [PATCH 1/7] filesystem: mark ptable msdos in tests at the right place In the new tests recently added to test_filesystem.py, the initial disk object was marked having a msdos partition table. This is fine for computing offsets manually. However, what really needs to be done is to mark the partition table as msdos in the YAML itself. Otherwise, the disk is reformatted as GPT. This makes gap functions use the right alignment data when computing the list of gaps available. Sadly it breaks the tests because of other issues, so I added FIXME tags in the broken tests. Signed-off-by: Olivier Gayot --- subiquity/models/tests/test_filesystem.py | 65 ++++++++++++++++++----- 1 file changed, 53 insertions(+), 12 deletions(-) diff --git a/subiquity/models/tests/test_filesystem.py b/subiquity/models/tests/test_filesystem.py index 4d566e9e..f83c7ac8 100644 --- a/subiquity/models/tests/test_filesystem.py +++ b/subiquity/models/tests/test_filesystem.py @@ -609,6 +609,7 @@ class TestAutoInstallConfig(unittest.TestCase): { 'type': 'disk', 'id': 'disk0', + 'ptable': 'msdos', }, { 'type': 'partition', @@ -638,9 +639,18 @@ class TestAutoInstallConfig(unittest.TestCase): }, ]) extended = model._one(type="partition", id="part1") - self.assertEqual( - extended.size, - disk.available_for_partitions - dehumanize_size('40M')) + # Disk test.img: 100 MiB, 104857600 bytes, 204800 sectors + # Units: sectors of 1 * 512 = 512 bytes + # Sector size (logical/physical): 512 bytes / 512 bytes + # I/O size (minimum/optimal): 512 bytes / 512 bytes + # Disklabel type: dos + # Disk identifier: 0x2cbec179 + # + # Device Boot Start End Sectors Size Id Type + # test.img1 2048 83967 81920 40M 83 Linux + # test.img2 83968 204799 120832 59M 5 Extended + # test.img5 86016 106495 20480 10M 83 Linux + self.assertEqual(extended.size, 120832 * 512) def test_logical_partition_remaining_size(self): model = make_model(bootloader=Bootloader.BIOS, storage_version=2) @@ -654,6 +664,7 @@ class TestAutoInstallConfig(unittest.TestCase): { 'type': 'disk', 'id': 'disk0', + 'ptable': 'msdos', }, { 'type': 'partition', @@ -674,12 +685,30 @@ class TestAutoInstallConfig(unittest.TestCase): 'offset': start_offset + ebr_space, }, ]) + disk = model._one(type="disk") extended = model._one(type="partition", id="part0") logical = model._one(type="partition", id="part5") + + ebr_space = disk.alignment_data().ebr_space + # Disk test.img: 100 MiB, 104857600 bytes, 204800 sectors + # Units: sectors of 1 * 512 = 512 bytes + # Sector size (logical/physical): 512 bytes / 512 bytes + # I/O size (minimum/optimal): 512 bytes / 512 bytes + # Disklabel type: dos + # Disk identifier: 0x16011ba9 + # + # Device Boot Start End Sectors Size Id Type + # test.img1 2048 83967 81920 40M 5 Extended + # test.img5 4096 83967 79872 39M 83 Linux + # At this point, there should be one large gap outside the extended - # partition and one smaller one inside the extended partition. + # partition and a smaller one inside the extended partition. # Make sure our logical partition picks up the smaller one. - self.assertEqual(logical.size, extended.size - ebr_space) + + # FIXME https://launchpad.net/bugs/1991929 + # The partition lacks 1MiB at the end + # self.assertEqual(logical.size, extended.size - ebr_space) + self.assertEqual(logical.size, extended.size - ebr_space - (1 << 20)) def test_partition_remaining_size_in_extended_and_logical(self): model = make_model(bootloader=Bootloader.BIOS, storage_version=2) @@ -692,6 +721,7 @@ class TestAutoInstallConfig(unittest.TestCase): { 'type': 'disk', 'id': 'disk0', + 'ptable': 'msdos', }, { 'type': 'partition', @@ -732,14 +762,25 @@ class TestAutoInstallConfig(unittest.TestCase): }, ]) extended = model._one(type="partition", id="part1") - p5 = model._one(type="partition", id="part5") p6 = model._one(type="partition", id="part6") - self.assertEqual( - extended.size, - disk.available_for_partitions - dehumanize_size('40M')) - self.assertEqual( - p6.size, - extended.size - p5.size - 2 * ebr_space) + # Disk test.img: 100 MiB, 104857600 bytes, 204800 sectors + # Units: sectors of 1 * 512 = 512 bytes + # Sector size (logical/physical): 512 bytes / 512 bytes + # I/O size (minimum/optimal): 512 bytes / 512 bytes + # Disklabel type: dos + # Disk identifier: 0x0b01e1ca + # + # Device Boot Start End Sectors Size Id Type + # test.img1 2048 83967 81920 40M 83 Linux + # test.img2 83968 204799 120832 59M 5 Extended + # test.img5 86016 106495 20480 10M 83 Linux + # test.img6 108544 204799 96256 47M 83 Linux + + self.assertEqual(extended.size, 120832 * 512) + # FIXME https://launchpad.net/bugs/1991929 + # the partition lacks 1MiB at the end + # self.assertEqual(p6.size, 96256 * 512) + self.assertEqual(p6.size, 96256 * 512 - (1 << 20)) def test_lv_percent(self): model = make_model() From 06f5e24904bd55acf2f7b557567b399a38cf2cc8 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Wed, 5 Oct 2022 18:59:14 +0200 Subject: [PATCH 2/7] filesystem: fix implem of available_for_partitions The available_for_partitions function wrongly assumed that the underlying disk had a GPT partition table. Updated the implementation to use the alignment data as expected. Signed-off-by: Olivier Gayot --- subiquity/models/filesystem.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 951ba2c7..f551b5eb 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -552,7 +552,7 @@ class _Device(_Formattable, ABC): @property def available_for_partitions(self): - return align_down(self.size, 1 << 20) - GPT_OVERHEAD + raise NotImplementedError def available(self): # A _Device is available if: @@ -605,6 +605,12 @@ class Disk(_Device): _info = attr.ib(default=None) + @property + def available_for_partitions(self): + margin_before = self.alignment_data().min_start_offset + margin_after = self.alignment_data().min_end_offset + return align_down(self.size, 1 << 20) - margin_before - margin_after + def alignment_data(self): ptable = self.ptable_for_new_partition() return self._m._partition_alignment_data[ptable] From 78ac4408d54e9aacf23ab0938bdd282d7d8aaeac Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Tue, 4 Oct 2022 15:05:19 +0200 Subject: [PATCH 3/7] filesystem: guess missing offsets in autoinstall When storage version 2 is used, partitions require an offset. When loading partitions via an autoinstall file, we now make sure to assign offsets automatically if the user did not specify offsets. https://bugs.launchpad.net/ubuntu/+source/subiquity/+bug/1991413 Signed-off-by: Olivier Gayot --- subiquity/models/filesystem.py | 47 +++++++++++++++++++++++ subiquity/models/tests/test_filesystem.py | 37 +++++------------- 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index f551b5eb..86ffdf18 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -1169,6 +1169,50 @@ class FilesystemModel(object): return candidates[0] return None + def assign_omitted_offsets(self): + """ For disks that use storage_version 2, assign offsets to partitions + that do not already have one. """ + for disk in self._all(type="disk"): + if disk._m.storage_version != 2: + continue + + info = disk.alignment_data() + + def au(v): # au == "align up" + r = v % info.part_align + if r: + return v + info.part_align - r + else: + return v + + def ad(v): # ad == "align down" + return v - v % info.part_align + + primary_parts = list(filter( + lambda x: not is_logical_partition(x), + disk.partitions())) + logical_parts = list(filter( + lambda x: is_logical_partition(x), + disk.partitions())) + + prev_end = info.min_start_offset + for part in primary_parts: + if part.offset is None: + part.offset = au(prev_end) + prev_end = part.offset + part.size + + if not logical_parts: + return + + extended_part = next( + filter(lambda x: x.flag == "extended", disk.partitions())) + + prev_end = extended_part.offset + for part in logical_parts: + if part.offset is None: + part.offset = au(prev_end + info.ebr_space) + prev_end = part.offset + part.size + def apply_autoinstall_config(self, ai_config): disks = self.all_disks() for action in ai_config: @@ -1194,6 +1238,9 @@ class FilesystemModel(object): action['serial'] = disk.serial self._actions = self._actions_from_config( ai_config, self._probe_data['blockdev'], is_probe_data=False) + + self.assign_omitted_offsets() + for p in self._all(type="partition") + self._all(type="lvm_partition"): # NOTE For logical partitions (DOS), the parent is set to the disk, # not the extended partition. diff --git a/subiquity/models/tests/test_filesystem.py b/subiquity/models/tests/test_filesystem.py index f83c7ac8..9a163cd1 100644 --- a/subiquity/models/tests/test_filesystem.py +++ b/subiquity/models/tests/test_filesystem.py @@ -599,10 +599,7 @@ class TestAutoInstallConfig(unittest.TestCase): def test_extended_partition_remaining_size(self): model = make_model(bootloader=Bootloader.BIOS, storage_version=2) - disk = make_disk(model, serial='aaaa', size=dehumanize_size("100M"), - ptable='msdos') - ebr_space = disk.alignment_data().ebr_space - start_offset = disk.alignment_data().min_start_offset + make_disk(model, serial='aaaa', size=dehumanize_size("100M")) fake_up_blockdata(model) model.apply_autoinstall_config([ @@ -616,7 +613,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'id': 'part0', 'device': 'disk0', 'size': dehumanize_size('40M'), - 'offset': start_offset, }, { 'type': 'partition', @@ -624,8 +620,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': -1, 'flag': 'extended', - # p0 offset + p0 size - 'offset': start_offset + dehumanize_size('40M'), }, { 'type': 'partition', @@ -634,8 +628,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': dehumanize_size('10M'), 'flag': 'logical', - # p1 (extended) offset + ebr_space - 'offset': start_offset + dehumanize_size('40M') + ebr_space, }, ]) extended = model._one(type="partition", id="part1") @@ -654,10 +646,7 @@ class TestAutoInstallConfig(unittest.TestCase): def test_logical_partition_remaining_size(self): model = make_model(bootloader=Bootloader.BIOS, storage_version=2) - disk = make_disk(model, serial='aaaa', size=dehumanize_size("100M"), - ptable='msdos') - ebr_space = disk.alignment_data().ebr_space - start_offset = disk.alignment_data().min_start_offset + make_disk(model, serial='aaaa', size=dehumanize_size("100M")) fake_up_blockdata(model) model.apply_autoinstall_config([ @@ -672,7 +661,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': dehumanize_size('40M'), 'flag': 'extended', - 'offset': start_offset, }, { 'type': 'partition', @@ -681,8 +669,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': -1, 'flag': 'logical', - # p0 (extended) offset + ebr_space - 'offset': start_offset + ebr_space, }, ]) disk = model._one(type="disk") @@ -705,6 +691,8 @@ class TestAutoInstallConfig(unittest.TestCase): # partition and a smaller one inside the extended partition. # Make sure our logical partition picks up the smaller one. + self.assertEqual(extended.offset, 2048 * 512) + self.assertEqual(logical.offset, 4096 * 512) # FIXME https://launchpad.net/bugs/1991929 # The partition lacks 1MiB at the end # self.assertEqual(logical.size, extended.size - ebr_space) @@ -712,10 +700,7 @@ class TestAutoInstallConfig(unittest.TestCase): def test_partition_remaining_size_in_extended_and_logical(self): model = make_model(bootloader=Bootloader.BIOS, storage_version=2) - disk = make_disk(model, serial='aaaa', size=dehumanize_size("100M"), - ptable='msdos') - ebr_space = disk.alignment_data().ebr_space - start_offset = disk.alignment_data().min_start_offset + make_disk(model, serial='aaaa', size=dehumanize_size("100M")) fake_up_blockdata(model) model.apply_autoinstall_config([ { @@ -728,7 +713,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'id': 'part0', 'device': 'disk0', 'size': dehumanize_size('40M'), - 'offset': start_offset, }, { 'type': 'partition', @@ -736,8 +720,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': -1, 'flag': 'extended', - # p0 offset + size of p0 - 'offset': start_offset + dehumanize_size('40M'), }, { 'type': 'partition', @@ -746,8 +728,6 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': dehumanize_size('10M'), 'flag': 'logical', - # p1 offset + ebr_space - 'offset': start_offset + dehumanize_size('40M') + ebr_space, }, { 'type': 'partition', @@ -756,12 +736,10 @@ class TestAutoInstallConfig(unittest.TestCase): 'device': 'disk0', 'size': -1, 'flag': 'logical', - # p5 offset + p5 size + ebr_space - 'offset': start_offset + dehumanize_size('40M') + ebr_space \ - + dehumanize_size('10M') + ebr_space }, ]) extended = model._one(type="partition", id="part1") + p5 = model._one(type="partition", id="part5") p6 = model._one(type="partition", id="part6") # Disk test.img: 100 MiB, 104857600 bytes, 204800 sectors # Units: sectors of 1 * 512 = 512 bytes @@ -776,7 +754,10 @@ class TestAutoInstallConfig(unittest.TestCase): # test.img5 86016 106495 20480 10M 83 Linux # test.img6 108544 204799 96256 47M 83 Linux + self.assertEqual(extended.offset, 83968 * 512) self.assertEqual(extended.size, 120832 * 512) + self.assertEqual(p5.offset, 86016 * 512) + self.assertEqual(p6.offset, 108544 * 512) # FIXME https://launchpad.net/bugs/1991929 # the partition lacks 1MiB at the end # self.assertEqual(p6.size, 96256 * 512) From b831d7ccae2ab96378bce73ed47606e3bc19d27e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 6 Oct 2022 14:29:03 +0200 Subject: [PATCH 4/7] filesystem: fix use of negative size in gaps calculations When size: -1 is specified on a given partition, we attempt to determine the its right size by looping through the partitions and computing a list of available gaps. That said, when looping through the partitions, we also include the one which has an incomplete (i.e. = -1) size. This makes the computation rely on a negative value and this often leads to incorrect result. Fixed by excluding the current partition when determining its appropriate size. https://bugs.launchpad.net/ubuntu/+source/subiquity/+bug/1991929 Signed-off-by: Olivier Gayot --- subiquity/models/filesystem.py | 4 ++++ subiquity/models/tests/test_filesystem.py | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 86ffdf18..04a04934 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -1262,6 +1262,10 @@ class FilesystemModel(object): "{} has negative size but is not final partition " "of {}".format(p, parent)) + # Exclude the current partition itself so that its + # incomplete size is not used as is. + filtered_parent._partitions.remove(p) + from subiquity.common.filesystem.gaps import ( largest_gap_size, ) diff --git a/subiquity/models/tests/test_filesystem.py b/subiquity/models/tests/test_filesystem.py index 9a163cd1..cd3c1adb 100644 --- a/subiquity/models/tests/test_filesystem.py +++ b/subiquity/models/tests/test_filesystem.py @@ -693,10 +693,7 @@ class TestAutoInstallConfig(unittest.TestCase): self.assertEqual(extended.offset, 2048 * 512) self.assertEqual(logical.offset, 4096 * 512) - # FIXME https://launchpad.net/bugs/1991929 - # The partition lacks 1MiB at the end - # self.assertEqual(logical.size, extended.size - ebr_space) - self.assertEqual(logical.size, extended.size - ebr_space - (1 << 20)) + self.assertEqual(logical.size, extended.size - ebr_space) def test_partition_remaining_size_in_extended_and_logical(self): model = make_model(bootloader=Bootloader.BIOS, storage_version=2) @@ -758,10 +755,7 @@ class TestAutoInstallConfig(unittest.TestCase): self.assertEqual(extended.size, 120832 * 512) self.assertEqual(p5.offset, 86016 * 512) self.assertEqual(p6.offset, 108544 * 512) - # FIXME https://launchpad.net/bugs/1991929 - # the partition lacks 1MiB at the end - # self.assertEqual(p6.size, 96256 * 512) - self.assertEqual(p6.size, 96256 * 512 - (1 << 20)) + self.assertEqual(p6.size, 96256 * 512) def test_lv_percent(self): model = make_model() From 01060fc14b22ff0348d43cd2dc5eb6b9adbb2259 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 6 Oct 2022 15:08:32 +0200 Subject: [PATCH 5/7] filesystem: add complex use-case as a test for offsets and sizes Signed-off-by: Olivier Gayot --- subiquity/models/tests/test_filesystem.py | 96 +++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/subiquity/models/tests/test_filesystem.py b/subiquity/models/tests/test_filesystem.py index cd3c1adb..20ca31f6 100644 --- a/subiquity/models/tests/test_filesystem.py +++ b/subiquity/models/tests/test_filesystem.py @@ -757,6 +757,102 @@ class TestAutoInstallConfig(unittest.TestCase): self.assertEqual(p6.offset, 108544 * 512) self.assertEqual(p6.size, 96256 * 512) + def test_partition_remaining_size_in_extended_and_logical_multiple(self): + model = make_model(bootloader=Bootloader.BIOS, storage_version=2) + make_disk(model, serial='aaaa', size=dehumanize_size("20G")) + fake_up_blockdata(model) + model.apply_autoinstall_config([ + { + 'type': 'disk', + 'id': 'disk0', + 'ptable': 'msdos', + }, + { + 'type': 'partition', + 'flag': 'boot', + 'device': 'disk0', + 'size': dehumanize_size('1G'), + 'id': 'partition-boot', + }, + { + 'type': 'partition', + 'device': 'disk0', + 'size': dehumanize_size('6G'), + 'id': 'partition-root', + }, + { + 'type': 'partition', + 'device': 'disk0', + 'size': dehumanize_size('100M'), + 'id': 'partition-swap', + }, + { + 'type': 'partition', + 'device': 'disk0', + 'size': -1, + 'flag': 'extended', + 'id': 'partition-extended', + }, + { + 'type': 'partition', + 'device': 'disk0', + 'size': dehumanize_size('1G'), + 'flag': 'logical', + 'id': 'partition-tmp', + }, + { + 'type': 'partition', + 'device': 'disk0', + 'size': dehumanize_size('2G'), + 'flag': 'logical', + 'id': 'partition-var', + }, + { + 'type': 'partition', + 'device': 'disk0', + 'size': -1, + 'flag': 'logical', + 'id': 'partition-home', + } + ]) + p_boot = model._one(type="partition", id="partition-boot") + p_root = model._one(type="partition", id="partition-root") + p_swap = model._one(type="partition", id="partition-swap") + p_extended = model._one(type="partition", id="partition-extended") + p_tmp = model._one(type="partition", id="partition-tmp") + p_var = model._one(type="partition", id="partition-var") + p_home = model._one(type="partition", id="partition-home") + + # Disk test.img: 20 GiB, 21474836480 bytes, 41943040 sectors + # Units: sectors of 1 * 512 = 512 bytes + # Sector size (logical/physical): 512 bytes / 512 bytes + # I/O size (minimum/optimal): 512 bytes / 512 bytes + # Disklabel type: dos + # Disk identifier: 0xfbc457e5 + # + # Device Boot Start End Sectors Size Id Type + # test.img1 2048 2099199 2097152 1G 83 Linux + # test.img2 2099200 14682111 12582912 6G 83 Linux + # test.img3 14682112 14886911 204800 100M 82 Linux swap ... + # test.img4 14886912 41943039 27056128 12,9G 5 Extended + # test.img5 14888960 16986111 2097152 1G 83 Linux + # test.img6 16988160 21182463 4194304 2G 83 Linux + # test.img7 21184512 41943039 20758528 9,9G 83 Linux + self.assertEqual(p_boot.offset, 2048 * 512) + self.assertEqual(p_boot.size, 2097152 * 512) + self.assertEqual(p_root.offset, 2099200 * 512) + self.assertEqual(p_root.size, 12582912 * 512) + self.assertEqual(p_swap.offset, 14682112 * 512) + self.assertEqual(p_swap.size, 204800 * 512) + self.assertEqual(p_extended.offset, 14886912 * 512) + self.assertEqual(p_extended.size, 27056128 * 512) + self.assertEqual(p_tmp.offset, 14888960 * 512) + self.assertEqual(p_tmp.size, 2097152 * 512) + self.assertEqual(p_var.offset, 16988160 * 512) + self.assertEqual(p_var.size, 4194304 * 512) + self.assertEqual(p_home.offset, 21184512 * 512) + self.assertEqual(p_home.size, 20758528 * 512) + def test_lv_percent(self): model = make_model() make_disk(model, serial='aaaa', size=dehumanize_size("100M")) From d27fec6480fd5f30b10fc1453dd35f0cfb7f0285 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Fri, 7 Oct 2022 09:41:24 +0200 Subject: [PATCH 6/7] filesystem: split logical and primary using more_itertools.partition Signed-off-by: Olivier Gayot --- apt-deps.txt | 1 + subiquity/models/filesystem.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/apt-deps.txt b/apt-deps.txt index 03e127f1..99377942 100644 --- a/apt-deps.txt +++ b/apt-deps.txt @@ -25,6 +25,7 @@ python3-dev python3-distutils-extra python3-flake8 python3-jsonschema +python3-more-itertools python3-nose python3-parameterized python3-pip diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 04a04934..2a69184c 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -26,6 +26,8 @@ import pathlib import platform import tempfile +import more_itertools + from curtin import storage_config from curtin.block import partition_kname from curtin.util import human2bytes @@ -1188,11 +1190,9 @@ class FilesystemModel(object): def ad(v): # ad == "align down" return v - v % info.part_align - primary_parts = list(filter( - lambda x: not is_logical_partition(x), - disk.partitions())) - logical_parts = list(filter( - lambda x: is_logical_partition(x), + # Extended is considered a primary partition too. + primary_parts, logical_parts = map(list, more_itertools.partition( + is_logical_partition, disk.partitions())) prev_end = info.min_start_offset From c20457818205718e850675dd4477b5c3096634dc Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 30 Oct 2022 15:00:49 +0100 Subject: [PATCH 7/7] filesystem: don't consider a mix of storage version when assigning offsets Storage version 2 is a global setting. Having one disk use storage version 1 and another with storage version 2 should not be possible and should not be considered a valid use-case. Signed-off-by: Olivier Gayot --- subiquity/models/filesystem.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 2a69184c..3c7961a6 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -1172,12 +1172,12 @@ class FilesystemModel(object): return None def assign_omitted_offsets(self): - """ For disks that use storage_version 2, assign offsets to partitions - that do not already have one. """ - for disk in self._all(type="disk"): - if disk._m.storage_version != 2: - continue + """ Assign offsets to partitions that do not already have one. + This method does nothing for storage version 1. """ + if self.storage_version != 2: + return + for disk in self._all(type="disk"): info = disk.alignment_data() def au(v): # au == "align up"