From a5d3ba87c5a4535dccc2239938c83c904343628d Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Thu, 14 Nov 2024 14:53:28 +0100 Subject: [PATCH] Make GPT default label type on all architectures Exceptions are DASD drives on s390 and 32bit ARM. Everywhere else GPT will be default. --- blivet/formats/disklabel.py | 11 +++++----- .../formats_tests/disklabel_test.py | 20 +++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/blivet/formats/disklabel.py b/blivet/formats/disklabel.py index f2857f07b..8b39dc793 100644 --- a/blivet/formats/disklabel.py +++ b/blivet/formats/disklabel.py @@ -220,12 +220,13 @@ def parted_device(self): @classmethod def get_platform_label_types(cls): - label_types = ["msdos", "gpt"] + # always prefer gpt except for configurations below + label_types = ["gpt", "msdos"] if arch.is_pmac(): label_types = ["mac"] - # always prefer gpt on aarch64, x86_64, and EFI plats except 32-bit ARM - elif arch.is_aarch64() or arch.is_x86(bits=64) or (arch.is_efi() and not arch.is_arm()): - label_types = ["gpt", "msdos"] + # prefet msdos on 32-bit ARM + elif arch.is_arm(): + label_types = ["msdos", "gpt"] elif arch.is_s390(): label_types += ["dasd"] @@ -254,7 +255,7 @@ def _get_best_label_type(self): if arch.is_s390(): if blockdev.s390.dasd_is_fba(self.device): # the device is FBA DASD - return "msdos" + return "gpt" elif self.parted_device.type == parted.DEVICE_DASD: # the device is DASD return "dasd" diff --git a/tests/unit_tests/formats_tests/disklabel_test.py b/tests/unit_tests/formats_tests/disklabel_test.py index 9f6e4542e..823a36630 100644 --- a/tests/unit_tests/formats_tests/disklabel_test.py +++ b/tests/unit_tests/formats_tests/disklabel_test.py @@ -71,7 +71,7 @@ def test_platform_label_types(self, arch): arch.is_pmac.return_value = False arch.is_x86.return_value = False - self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt"]) + self.assertEqual(disklabel_class.get_platform_label_types(), ["gpt", "msdos"]) arch.is_pmac.return_value = True self.assertEqual(disklabel_class.get_platform_label_types(), ["mac"]) @@ -100,7 +100,7 @@ def test_platform_label_types(self, arch): arch.is_efi.return_value = False arch.is_s390.return_value = True - self.assertEqual(disklabel_class.get_platform_label_types(), ["msdos", "gpt", "dasd"]) + self.assertEqual(disklabel_class.get_platform_label_types(), ["gpt", "msdos", "dasd"]) arch.is_s390.return_value = False def test_label_type_size_check(self): @@ -121,14 +121,14 @@ def test_label_type_size_check(self): with patch.object(blivet.formats.disklabel.DiskLabel, "parted_device", new=PropertyMock(return_value=None)): # no parted device -> no passing size check - self.assertEqual(dl._label_type_size_check("msdos"), False) + self.assertEqual(dl._label_type_size_check("gpt"), False) @patch("blivet.formats.disklabel.arch") def test_best_label_type(self, arch): """ 1. is always in _disklabel_types 2. is the default unless the device is too long for the default - 3. is msdos for fba dasd on S390 + 3. is gpt for fba dasd on S390 4. is dasd for non-fba dasd on S390 """ dl = blivet.formats.disklabel.DiskLabel() @@ -144,17 +144,17 @@ def test_best_label_type(self, arch): arch.is_x86.return_value = False with patch.object(dl, '_label_type_size_check') as size_check: - # size check passes for first type ("msdos") + # size check passes for first type ("gpt") size_check.return_value = True - self.assertEqual(dl._get_best_label_type(), "msdos") + self.assertEqual(dl._get_best_label_type(), "gpt") # size checks all fail -> label type is None size_check.return_value = False self.assertEqual(dl._get_best_label_type(), None) - # size check passes on second call -> label type is "gpt" (second in platform list) + # size check passes on second call -> label type is "msdos" (second in platform list) size_check.side_effect = [False, True] - self.assertEqual(dl._get_best_label_type(), "gpt") + self.assertEqual(dl._get_best_label_type(), "msdos") arch.is_pmac.return_value = True with patch.object(dl, '_label_type_size_check') as size_check: @@ -175,10 +175,10 @@ def test_best_label_type(self, arch): size_check.return_value = True with patch("blivet.formats.disklabel.blockdev.s390") as _s390: _s390.dasd_is_fba.return_value = False - self.assertEqual(dl._get_best_label_type(), "msdos") + self.assertEqual(dl._get_best_label_type(), "gpt") _s390.dasd_is_fba.return_value = True - self.assertEqual(dl._get_best_label_type(), "msdos") + self.assertEqual(dl._get_best_label_type(), "gpt") _s390.dasd_is_fba.return_value = False dl._parted_device.type = parted.DEVICE_DASD