rhel85/90: allow specifying the boot partition for the grub2 stage

Specifying the boot partition filesystem UUID in grub2 stage is required
in case the `/boot` mountpoint is on a separate partition. This is the
case of RHEL-8.5 and RHEL-9.0 `ami` and `ec2` images.

Extend `disk.PartitionTable` with a new `BootPartition` method, which
returns a pointer to partition with FS mountpoint `/boot` if there is
such partition, or `nil` otherwise.

Extend the RHEL-8.5 and RHEL-9.0 code creating options structure for
grub2 osbuild stage to include the boot partition in case it has been
provided.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2021-08-11 11:24:30 +02:00 committed by Tomas Hozza
parent a9c280a2fc
commit 7ac1d68fb6
5 changed files with 33 additions and 4 deletions

View file

@ -120,6 +120,23 @@ func (pt PartitionTable) RootPartition() *Partition {
return nil
}
// Returns the /boot partition (the partition whose filesystem has /boot as
// a mountpoint) of the partition table. Nil is returned if there's no such
// partition.
func (pt PartitionTable) BootPartition() *Partition {
for _, p := range pt.Partitions {
if p.Filesystem == nil {
continue
}
if p.Filesystem.Mountpoint == "/boot" {
return &p
}
}
return nil
}
// Returns the index of the boot partition: the partition whose filesystem has
// /boot as a mountpoint. If there is no explicit boot partition, the root
// partition is returned.