Skip to content

Commit

Permalink
Support partitioning of hybrid boot disks
Browse files Browse the repository at this point in the history
Anaconda needs to be able to create hybrid boot disks. For example:

  clearpart --all --initlabel --disklabel=gpt
  part prepboot  --size=4    --fstype=prepboot
  part biosboot  --size=1    --fstype=biosboot
  part /boot/efi --size=100  --fstype=efi
  part /boot     --size=1000 --fstype=ext4 --label=boot
  part /         --grow      --fstype xfs

However, this kickstart snippet is not working with two or more disks.
The bootloader-related partitions should be all created on the disk
the computer will boot from, but Blivet does that only for platform
-specific partitions. The rest of them are created on any disk with
enough space.

It looks like this can be easily fixed by setting the same weight
to all of these partitions regardless of the current platform.

See: rhinstaller/anaconda#5298
  • Loading branch information
poncovka committed Nov 24, 2023
1 parent 793ec72 commit 63474c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
11 changes: 3 additions & 8 deletions blivet/devices/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,24 +454,19 @@ def _get_weight(self):

# now we have the weights for varying mountpoints and fstypes by platform
weight = 0

if self.format.mountable and self.format.mountpoint == "/boot":
weight = 2000
elif (self.format.mountable and
self.format.mountpoint == "/boot/efi" and
self.format.type in ("efi", "macefi") and
arch.is_efi()):
self.format.type in ("efi", "macefi")):
weight = 5000
elif arch.is_x86() and self.format.type == "biosboot" and not arch.is_efi():
elif self.format.type in ("biosboot", "appleboot", "prepboot"):
weight = 5000
elif self.format.mountable and arch.is_arm():
# On ARM images '/' must be the last partition.
if self.format.mountpoint == "/":
weight = -100
elif arch.is_ppc():
if arch.is_pmac() and self.format.type == "appleboot":
weight = 5000
elif arch.is_ipseries() and self.format.type == "prepboot":
weight = 5000

return weight

Expand Down
16 changes: 8 additions & 8 deletions tests/unit_tests/devices_test/partition_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_weight_1(self, *patches):

fmt.mountpoint = "/boot/efi"
fmt.type = "efi"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

#
# UEFI
Expand All @@ -102,7 +102,7 @@ def test_weight_1(self, *patches):
self.assertEqual(dev.weight, 5000)

fmt.type = "biosboot"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

fmt.mountpoint = "/"
self.assertEqual(dev.weight, 0)
Expand All @@ -129,30 +129,30 @@ def test_weight_1(self, *patches):
self.assertEqual(dev.weight, 0)

fmt.type = "prepboot"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

fmt.type = "appleboot"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

arch.is_pmac.return_value = True
self.assertEqual(dev.weight, 5000)

fmt.type = "prepboot"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

arch.is_pmac.return_value = False
arch.is_ipseries.return_value = True
self.assertEqual(dev.weight, 5000)

fmt.type = "appleboot"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

fmt.mountpoint = "/boot/efi"
fmt.type = "efi"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

fmt.type = "biosboot"
self.assertEqual(dev.weight, 0)
self.assertEqual(dev.weight, 5000)

fmt.mountpoint = "/"
self.assertEqual(dev.weight, 0)
Expand Down

0 comments on commit 63474c0

Please sign in to comment.