Skip to content

disk: Add support for raw partitions, custom types and UKIBoot partition layout#1685

Merged
mvo5 merged 2 commits into
osbuild:mainfrom
martinezjavier:disk-ukiboot-support
Aug 5, 2025
Merged

disk: Add support for raw partitions, custom types and UKIBoot partition layout#1685
mvo5 merged 2 commits into
osbuild:mainfrom
martinezjavier:disk-ukiboot-support

Conversation

@martinezjavier

Copy link
Copy Markdown
Contributor

This pull-request adds the capability to create raw (unformatted) partitions, for custom boot setups that require partitions with specific GPT types but without a filesystem (e.g: ukiboot).

It also adds the specific GPT type UUIDs for UKIBoot (UKIBootPartitionUUID) and the UKIBoot control (UKIBootCtlPartitionUUID) partition types. And the logic to properly map these types with the UKIBoot partitions, based on their labels.

Having this support will allow bootc-image-builder to embedded customization files to generate images that can be booted using UKIBoot.

@martinezjavier martinezjavier requested review from a team and achilleas-k as code owners July 24, 2025 07:58
@thozza thozza requested a review from mvo5 July 24, 2025 08:01

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution.

Unfortunately, I'm not a fan of this approach and the changes done to addPlainPartition(). My suggestion would be to allow users to define this scenario by explicit options in the FS customizations, instead of having a special case logic if specific options are not set at all (since it could be just a user error, which would now get caught by this special case).

I would also like you to extend unit tests to cover cases such as no partition label being set, etc...

Comment thread pkg/disk/partition_table.go Outdated
Comment thread pkg/disk/partition_table.go Outdated
Comment thread pkg/disk/partition_table.go Outdated
Comment thread pkg/disk/partition_table.go

@mvo5 mvo5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks nice, two tiny (optional) suggestions and a question inline. We also want @achilleas-k review here as he is the expert in this area :)

Comment thread pkg/disk/partition_table.go Outdated
Comment thread pkg/disk/partition_table_test.go
Comment thread pkg/disk/partition_table_test.go Outdated
@martinezjavier martinezjavier force-pushed the disk-ukiboot-support branch 3 times, most recently from 36d7cc7 to d8159dd Compare July 25, 2025 07:57
@martinezjavier

Copy link
Copy Markdown
Contributor Author

@thozza @mvo5 I've updated my branch with changes to address your feedback and suggestions.

The changes for v2 are the following:

  • Introduces an explicit FSType: "none" to make the intent clear when a plain partition should be left unformatted instead of doing it implicitly when fs_type and mountpoint were not defined.
  • Refactor addPlainPartition() to remove the if/else logic and handle the new "none" type in a switch statement.
  • Add a check in validatePlain() to return an error if a "none" partition has a mountpoint specified.
  • Modify GenUUID() to skip UUID generation for the "none" type (since there's no filesystem in the partition, the filesystem UUID should not be set).
  • Add and update unit tests to cover the new type and its constraints.
  • Fix the formatting issues reported by ./tools/prepare-source.sh

achilleas-k
achilleas-k previously approved these changes Jul 28, 2025

@achilleas-k achilleas-k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. LGTM. One very small comment, but not a blocker. Feel free to ignore.

Comment thread pkg/disk/partition_table.go Outdated
Comment on lines +1430 to +1438
case fstype == "none":
if partition.Label != "" {
typeName = partition.Label
} else {
typeName = "data"
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiniest of nitpicks:

I'd prefer if the ukiboot_a and ukiboot_b labels mapping to the ukiboot type happened here instead of in the getPartitionTypeIDfor() function. It's not very important, but I think of the types that get passed to getPartitionTypeIDfor() to be common names for the types of partitions we handle. In fact, I was considering changing that to an enum with type names matching the names as they appear in fdisk. So with that logic, the getPartitionTypeIDfor() function would only know those types and it's up to the caller to make the decision based on mountpoint or label.

So this would then be:

case fstype == "none":
    switch partition.Label {
    case "ukiboot_a", "ukiboot_b":
        typeName = "ukiboot"
    case "ukibootctl":
        typeName = "ukibootctl"
    default:
        typeName = "data"
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achilleas-k I've pushed a v3 addressing this comment. The full diff between v2 and v3 is the following:

diff --git a/pkg/disk/disk.go b/pkg/disk/disk.go
index 4c4b206ba99b..7e8d2d498af2 100644
--- a/pkg/disk/disk.go
+++ b/pkg/disk/disk.go
@@ -175,7 +175,7 @@ func getPartitionTypeIDfor(ptType PartitionTableType, partTypeName string, archi
                        default:
                                return "", fmt.Errorf("unknown or unsupported architecture enum value: %d", architecture)
                        }
-               case "ukiboot_a", "ukiboot_b":
+               case "ukiboot":
                        return UKIBootPartitionUUID, nil
                case "ukibootctl":
                        return UKIBootCtlPartitionUUID, nil
diff --git a/pkg/disk/partition_table.go b/pkg/disk/partition_table.go
index dce7382434bf..92be355c21bd 100644
--- a/pkg/disk/partition_table.go
+++ b/pkg/disk/partition_table.go
@@ -1428,9 +1428,12 @@ func addPlainPartition(pt *PartitionTable, partition blueprint.PartitionCustomiz
                case partition.Mountpoint == "/boot":
                        typeName = "boot"
                case fstype == "none":
-                       if partition.Label != "" {
-                               typeName = partition.Label
-                       } else {
+                       switch partition.Label {
+                       case "ukiboot_a", "ukiboot_b":
+                               typeName = "ukiboot"
+                       case "ukibootctl":
+                               typeName = "ukibootctl"
+                       default:
                                typeName = "data"
                        }
                case fstype == "swap":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Your diff here looks good, but I don't see the change in the PR diff.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achilleas-k yeah, because since that change @mvo5 and @thozza had more comments and at the end the mapping was gone :)

@mvo5 mvo5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, lots to like here - but I do wonder if we really need to add knowledge about the uki boot here or if adding "fstype" none is enough. I mean, it might be fine, how widely used is it?

Comment thread pkg/disk/disk.go Outdated
Comment thread pkg/disk/partition_table.go Outdated

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all the changes, this looks much better now and almost perfect (please see my inline comment).

Comment thread pkg/disk/partition_table.go Outdated
@croissanne croissanne removed their request for review July 29, 2025 09:51
@martinezjavier martinezjavier force-pushed the disk-ukiboot-support branch 5 times, most recently from fdbaad4 to ac36012 Compare July 29, 2025 11:12

@mvo5 mvo5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Two tiny question/suggestion inline, if you are busy we can take care of it. This may need a decision by e.g. @achilleas-k if we allow payload to be nil or add a new disk.Raw{} structure

Comment thread pkg/disk/disk.go Outdated
Comment thread pkg/disk/partition_table.go Outdated
@mvo5 mvo5 requested a review from thozza July 29, 2025 16:28
@martinezjavier martinezjavier force-pushed the disk-ukiboot-support branch 4 times, most recently from 5e519db to 37849bf Compare July 31, 2025 14:20
mvo5
mvo5 previously approved these changes Jul 31, 2025

@mvo5 mvo5 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love how simple this has become, one tiny suggestion about a comment but approving already as I think that its optional (but would be nice I think)

Comment thread pkg/disk/partition_table_test.go
@martinezjavier martinezjavier force-pushed the disk-ukiboot-support branch 2 times, most recently from 331bc3a to f020eb3 Compare July 31, 2025 15:19
mvo5
mvo5 previously approved these changes Jul 31, 2025

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM. I appreciate your patience.

@mvo5 mvo5 enabled auto-merge August 4, 2025 08:09
@alexlarsson

Copy link
Copy Markdown
Contributor

Seems like these failures are some random registry issues. Can we re-run them?

@supakeen

supakeen commented Aug 4, 2025

Copy link
Copy Markdown
Member

Seems like these failures are some random registry issues. Can we re-run them?

Sadly no, Fedora's infra is having a bunch of issues at the moment. I'm asking around if we can make (some of) these checks non-required while this is going on.

Add the capability to create raw (unformatted) partitions, for custom boot
setups that require partitions with specific GPT types but no filesystems.

The plain partition with fs_type none doesn't have to specify a mountpoint
in its customization, similarly to plain swap partitions that also don't
have formatted filesystems.

For these raw partitions, the GPT partition type GUID can be specified. If
is not specified, the type defaults to the "data" partition type.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Add a test for the creation of UKIBoot and UKIBoot control partitions as
required by the UKIBoot protocol.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
@achilleas-k achilleas-k force-pushed the disk-ukiboot-support branch from 031dae2 to 856487f Compare August 5, 2025 17:21

@achilleas-k achilleas-k left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love how this turned out. Thanks for being so patient with our endless reviews.

LGTM!

@mvo5 mvo5 added this pull request to the merge queue Aug 5, 2025
Merged via the queue into osbuild:main with commit d8e380a Aug 5, 2025
22 of 23 checks passed
@martinezjavier

Copy link
Copy Markdown
Contributor Author

Love how this turned out. Thanks for being so patient with our endless reviews.

LGTM!

@achilleas-k @thozza @mvo5 on the contrary, thanks a lot folks for all your feedback and comments!

mvo5 added a commit to mvo5/blueprint that referenced this pull request Aug 6, 2025
This commit syncs the latest changes from the blueprint changes
in the images library.

See osbuild/image-builder#1685
mvo5 added a commit to mvo5/blueprint that referenced this pull request Aug 6, 2025
This commit syncs the latest changes from the blueprint changes
in the images library.

See osbuild/image-builder#1685
github-merge-queue Bot pushed a commit to osbuild/blueprint that referenced this pull request Aug 6, 2025
This commit syncs the latest changes from the blueprint changes
in the images library.

See osbuild/image-builder#1685
@martinezjavier martinezjavier deleted the disk-ukiboot-support branch August 10, 2025 03:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants