From 4ed82187eb215b4dcc8fc6a4ca211da3d88798b5 Mon Sep 17 00:00:00 2001 From: Simon de Vlieger Date: Thu, 2 Oct 2025 19:26:49 +0200 Subject: [PATCH] policy: allow /boot on btrfs Instead of requiring /boot to be a plain partition it is perfectly possible and allowable to have it on a btrfs subvolume. Needs some follow-up work in `images` to actually work. Also changes the test case to allow for this. Signed-off-by: Simon de Vlieger --- pkg/blueprint/disk_customizations.go | 13 +++++++++---- pkg/blueprint/disk_customizations_test.go | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/blueprint/disk_customizations.go b/pkg/blueprint/disk_customizations.go index 53c853e..4fcdbc8 100644 --- a/pkg/blueprint/disk_customizations.go +++ b/pkg/blueprint/disk_customizations.go @@ -517,12 +517,17 @@ func validateFilesystemType(path, fstype string) error { return nil } -// These mountpoints must be on a plain partition (i.e. not on LVM or btrfs). -var plainOnlyMountpoints = []string{ +// These mountpoints must be on a plain partition (i.e. not on LVM). +var plainOnlyMountpointsForLVM = []string{ "/boot", "/boot/efi", // not allowed by our global policies, but that might change } +// These mountpoints must be on a plain partition (i.e. not on btrfs). +var plainOnlyMountpointsForBtrfs = []string{ + "/boot/efi", // not allowed by our global policies, but that might change +} + var validPlainFSTypes = []string{ "ext4", "vfat", @@ -681,7 +686,7 @@ func (p *PartitionCustomization) validateLVM(mountpoints, vgnames map[string]boo } mountpoints[lv.Mountpoint] = true - if slices.Contains(plainOnlyMountpoints, lv.Mountpoint) { + if slices.Contains(plainOnlyMountpointsForLVM, lv.Mountpoint) { return fmt.Errorf("invalid mountpoint %q for logical volume", lv.Mountpoint) } @@ -722,7 +727,7 @@ func (p *PartitionCustomization) validateBtrfs(mountpoints map[string]bool) erro if mountpoints[subvol.Mountpoint] { return fmt.Errorf("duplicate mountpoint %q in partitioning customizations", subvol.Mountpoint) } - if slices.Contains(plainOnlyMountpoints, subvol.Mountpoint) { + if slices.Contains(plainOnlyMountpointsForBtrfs, subvol.Mountpoint) { return fmt.Errorf("invalid mountpoint %q for btrfs subvolume", subvol.Mountpoint) } mountpoints[subvol.Mountpoint] = true diff --git a/pkg/blueprint/disk_customizations_test.go b/pkg/blueprint/disk_customizations_test.go index 2ef207a..fa50533 100644 --- a/pkg/blueprint/disk_customizations_test.go +++ b/pkg/blueprint/disk_customizations_test.go @@ -777,7 +777,7 @@ func TestPartitioningValidation(t *testing.T) { }, expectedMsg: "invalid partitioning customizations:\ninvalid mountpoint \"/boot/efi\" for logical volume", }, - "boot-on-btrfs": { + "happy-boot-on-btrfs": { partitioning: &blueprint.DiskCustomization{ Partitions: []blueprint.PartitionCustomization{ { @@ -797,7 +797,7 @@ func TestPartitioningValidation(t *testing.T) { }, }, }, - expectedMsg: "invalid partitioning customizations:\ninvalid mountpoint \"/boot\" for btrfs subvolume", + expectedMsg: "", }, "bootefi-on-btrfs": { partitioning: &blueprint.DiskCustomization{