From 03400f568896f5ea092a6b05ea2a9d8f85ebb776 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2025 18:42:11 +0200 Subject: [PATCH 1/2] disk: pass default fs to FS customiaztions Tradtionally we did not pass the filesystem with the filesystem customizations which means that we always created "xfs". This is problematic on bootc systems that require us to use the container default filesystem and arguably also on fedora that declares its default fs to be "ext4" in our image definitions. So this commit changes the behavior so that the defaultFs is passed when creating custom mountpoints. This changes nothing on rhel/centos but does change the behavior on fedora - which should be fine as we can consider this a bugfix. The manifest diff shows that the fstype on fedora moves from xfs to ext4 for the filesystem customizations. --- cmd/osbuild-playground/my-image.go | 2 +- pkg/disk/btrfs.go | 4 +- pkg/disk/disk.go | 6 ++- pkg/disk/disk_test.go | 44 +++++++++++++------ pkg/disk/lvm.go | 7 +-- pkg/disk/lvm_test.go | 10 ++--- pkg/disk/partition_table.go | 37 +++++++++------- pkg/distro/bootc/partition.go | 2 +- pkg/distro/generic/imagetype.go | 6 ++- pkg/osbuild/device_test.go | 6 +-- pkg/osbuild/disk_test.go | 2 +- ...a_41-aarch64-server_ami-all_customizations | 2 +- ...dora_41-aarch64-server_qcow2-all_with_fips | 2 +- ...dora_41-aarch64-server_qcow2-oscap_generic | 2 +- ...dora_41-ppc64le-server_qcow2-all_with_fips | 2 +- ...dora_41-ppc64le-server_qcow2-oscap_generic | 2 +- ...fedora_41-s390x-server_qcow2-all_with_fips | 2 +- ...fedora_41-s390x-server_qcow2-oscap_generic | 2 +- ...ra_41-x86_64-server_ami-all_customizations | 2 +- ...edora_41-x86_64-server_qcow2-all_with_fips | 2 +- ...edora_41-x86_64-server_qcow2-oscap_generic | 2 +- ...a_42-aarch64-server_ami-all_customizations | 2 +- ...dora_42-aarch64-server_qcow2-all_with_fips | 2 +- ...dora_42-aarch64-server_qcow2-oscap_generic | 2 +- ...dora_42-ppc64le-server_qcow2-all_with_fips | 2 +- ...dora_42-ppc64le-server_qcow2-oscap_generic | 2 +- ...fedora_42-s390x-server_qcow2-all_with_fips | 2 +- ...fedora_42-s390x-server_qcow2-oscap_generic | 2 +- ...ra_42-x86_64-server_ami-all_customizations | 2 +- ...edora_42-x86_64-server_qcow2-all_with_fips | 2 +- ...edora_42-x86_64-server_qcow2-oscap_generic | 2 +- ...a_43-aarch64-server_ami-all_customizations | 2 +- ...dora_43-aarch64-server_qcow2-all_with_fips | 2 +- ...dora_43-aarch64-server_qcow2-oscap_generic | 2 +- ...dora_43-ppc64le-server_qcow2-all_with_fips | 2 +- ...dora_43-ppc64le-server_qcow2-oscap_generic | 2 +- ...fedora_43-s390x-server_qcow2-all_with_fips | 2 +- ...fedora_43-s390x-server_qcow2-oscap_generic | 2 +- ...ra_43-x86_64-server_ami-all_customizations | 2 +- ...edora_43-x86_64-server_qcow2-all_with_fips | 2 +- ...edora_43-x86_64-server_qcow2-oscap_generic | 2 +- 41 files changed, 108 insertions(+), 78 deletions(-) diff --git a/cmd/osbuild-playground/my-image.go b/cmd/osbuild-playground/my-image.go index 7be682f131..4fdbec5d7e 100644 --- a/cmd/osbuild-playground/my-image.go +++ b/cmd/osbuild-playground/my-image.go @@ -42,7 +42,7 @@ func (img *MyImage) InstantiateManifest(m *manifest.Manifest, } // TODO: add helper - pt, err := disk.NewPartitionTable(&basePT, nil, 0, partition.RawPartitioningMode, platform.GetArch(), nil, rng) + pt, err := disk.NewPartitionTable(&basePT, nil, 0, partition.RawPartitioningMode, platform.GetArch(), nil, "", rng) if err != nil { panic(err) } diff --git a/pkg/disk/btrfs.go b/pkg/disk/btrfs.go index b4ffb31963..2b360b39cc 100644 --- a/pkg/disk/btrfs.go +++ b/pkg/disk/btrfs.go @@ -19,6 +19,8 @@ type Btrfs struct { Subvolumes []BtrfsSubvolume `json:"subvolumes,omitempty" yaml:"subvolumes,omitempty"` } +var _ = MountpointCreator(&Btrfs{}) + func init() { payloadEntityMap["btrfs"] = reflect.TypeOf(Btrfs{}) } @@ -58,7 +60,7 @@ func (b *Btrfs) GetItemCount() uint { func (b *Btrfs) GetChild(n uint) Entity { return &b.Subvolumes[n] } -func (b *Btrfs) CreateMountpoint(mountpoint string, size uint64) (Entity, error) { +func (b *Btrfs) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { name := mountpoint if name == "/" { name = "root" diff --git a/pkg/disk/disk.go b/pkg/disk/disk.go index 875672b741..c35246c15c 100644 --- a/pkg/disk/disk.go +++ b/pkg/disk/disk.go @@ -374,9 +374,11 @@ type FSTabEntity interface { // A MountpointCreator is a container that is able to create new volumes. // // CreateMountpoint creates a new mountpoint with the given size and -// returns the entity that represents the new mountpoint. +// default filesystem and returns the entity that represents the new +// mountpoint. The defaultFs is only a hint and can be ignored by +// e.g. btrfs subvolumes. type MountpointCreator interface { - CreateMountpoint(mountpoint string, size uint64) (Entity, error) + CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) // AlignUp will align the given bytes according to the // requirements of the container type. diff --git a/pkg/disk/disk_test.go b/pkg/disk/disk_test.go index 8093f683a1..cb00b039ca 100644 --- a/pkg/disk/disk_test.go +++ b/pkg/disk/disk_test.go @@ -81,7 +81,7 @@ func TestDynamicallyResizePartitionTable(t *testing.T) { // math/rand is good enough in this case /* #nosec G404 */ rng := rand.New(rand.NewSource(0)) - newpt, err := disk.NewPartitionTable(&pt, mountpoints, 1024, partition.RawPartitioningMode, arch.ARCH_AARCH64, nil, rng) + newpt, err := disk.NewPartitionTable(&pt, mountpoints, 1024, partition.RawPartitioningMode, arch.ARCH_AARCH64, nil, "", rng) assert.NoError(t, err) assert.GreaterOrEqual(t, newpt.Size, expectedSize) } @@ -194,7 +194,7 @@ func TestCreatePartitionTable(t *testing.T) { if ptName == "luks+lvm" { ptMode = partition.AutoLVMPartitioningMode } - mpt, err := disk.NewPartitionTable(&pt, bp, uint64(13*MiB), ptMode, arch.ARCH_PPC64LE, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, bp, uint64(13*MiB), ptMode, arch.ARCH_PPC64LE, nil, "", rng) require.NoError(t, err, "Partition table generation failed: PT %q BP %q (%s)", ptName, bpName, err) assert.NotNil(mpt, "Partition table generation failed: PT %q BP %q (nil partition table)", ptName, bpName) assert.Greater(mpt.GetSize(), sumSizes(bp)) @@ -218,12 +218,12 @@ func TestCreatePartitionTableLVMify(t *testing.T) { for bpName, tbp := range testBlueprints { for ptName, pt := range testdisk.TestPartitionTables() { if tbp != nil && (ptName == "btrfs" || ptName == "luks") { - _, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, rng) + _, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.Error(err, "PT %q BP %q: should return an error with LVMPartitioningMode", ptName, bpName) continue } - mpt, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.NoError(err, "PT %q BP %q: Partition table generation failed: (%s)", ptName, bpName, err) rootPath := disk.EntityPath(mpt, "/") @@ -254,12 +254,12 @@ func TestCreatePartitionTableBtrfsify(t *testing.T) { for bpName, tbp := range testBlueprints { for ptName, pt := range testdisk.TestPartitionTables() { if ptName == "auto-lvm" || ptName == "luks" || ptName == "luks+lvm" { - _, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.BtrfsPartitioningMode, arch.ARCH_X86_64, nil, rng) + _, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.BtrfsPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.Error(err, "PT %q BP %q: should return an error with BtrfsPartitioningMode", ptName, bpName) continue } - mpt, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.BtrfsPartitioningMode, arch.ARCH_X86_64, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.BtrfsPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.NoError(err, "PT %q BP %q: Partition table generation failed: (%s)", ptName, bpName, err) rootPath := disk.EntityPath(mpt, "/") @@ -290,12 +290,12 @@ func TestCreatePartitionTableLVMOnly(t *testing.T) { for bpName, tbp := range testBlueprints { for ptName, pt := range testdisk.TestPartitionTables() { if ptName == "btrfs" || ptName == "luks" { - _, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.LVMPartitioningMode, arch.ARCH_S390X, nil, rng) + _, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.LVMPartitioningMode, arch.ARCH_S390X, nil, "", rng) assert.Error(err, "PT %q BP %q: should return an error with LVMPartitioningMode", ptName, bpName) continue } - mpt, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.LVMPartitioningMode, arch.ARCH_S390X, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, tbp, uint64(13*MiB), partition.LVMPartitioningMode, arch.ARCH_S390X, nil, "", rng) require.NoError(t, err, "PT %q BP %q: Partition table generation failed: (%s)", ptName, bpName, err) rootPath := disk.EntityPath(mpt, "/") @@ -447,7 +447,7 @@ func TestMinimumSizes(t *testing.T) { for idx, tc := range testCases { { // without LVM - mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.RawPartitioningMode, arch.ARCH_X86_64, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.RawPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.NoError(err) for mnt, minSize := range tc.ExpectedMinSizes { path := disk.EntityPath(mpt, mnt) @@ -461,7 +461,7 @@ func TestMinimumSizes(t *testing.T) { } { // with LVM - mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.NoError(err) for mnt, minSize := range tc.ExpectedMinSizes { path := disk.EntityPath(mpt, mnt) @@ -548,7 +548,7 @@ func TestLVMExtentAlignment(t *testing.T) { } for idx, tc := range testCases { - mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, nil, "", rng) assert.NoError(err) for mnt, expSize := range tc.ExpectedSizes { path := disk.EntityPath(mpt, mnt) @@ -577,7 +577,7 @@ func TestNewBootWithSizeLVMify(t *testing.T) { }, } - mpt, err := disk.NewPartitionTable(&pt, custom, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_AARCH64, nil, rng) + mpt, err := disk.NewPartitionTable(&pt, custom, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_AARCH64, nil, "", rng) assert.NoError(err) for idx, c := range custom { @@ -920,7 +920,7 @@ func TestMinimumSizesWithRequiredSizes(t *testing.T) { for idx, tc := range testCases { { // without LVM - mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.RawPartitioningMode, arch.ARCH_AARCH64, map[string]uint64{"/": 1 * GiB, "/usr": 3 * GiB}, rng) + mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.RawPartitioningMode, arch.ARCH_AARCH64, map[string]uint64{"/": 1 * GiB, "/usr": 3 * GiB}, "", rng) assert.NoError(err) for mnt, minSize := range tc.ExpectedMinSizes { path := disk.EntityPath(mpt, mnt) @@ -934,7 +934,7 @@ func TestMinimumSizesWithRequiredSizes(t *testing.T) { } { // with LVM - mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_AARCH64, map[string]uint64{"/": 1 * GiB, "/usr": 3 * GiB}, rng) + mpt, err := disk.NewPartitionTable(&pt, tc.Blueprint, uint64(3*GiB), partition.AutoLVMPartitioningMode, arch.ARCH_AARCH64, map[string]uint64{"/": 1 * GiB, "/usr": 3 * GiB}, "", rng) assert.NoError(err) for mnt, minSize := range tc.ExpectedMinSizes { path := disk.EntityPath(mpt, mnt) @@ -1056,3 +1056,19 @@ func TestForEachMountable(t *testing.T) { }) } } + +func TestCreatePartitionTableDefaultFs(t *testing.T) { + // math/rand is good enough in this case + /* #nosec G404 */ + rng := rand.New(rand.NewSource(13)) + + pt := testdisk.TestPartitionTables()["plain"] + fsCust := []blueprint.FilesystemCustomization{ + {Mountpoint: "/var/stuff", MinSize: 10 * datasizes.GiB}, + } + + mpt, err := disk.NewPartitionTable(&pt, fsCust, 0, partition.RawPartitioningMode, arch.ARCH_X86_64, nil, "ext4", rng) + assert.NoError(t, err) + assert.Equal(t, "/var/stuff", mpt.Partitions[4].Payload.(*disk.Filesystem).Mountpoint) + assert.Equal(t, "ext4", mpt.Partitions[4].Payload.(*disk.Filesystem).Type) +} diff --git a/pkg/disk/lvm.go b/pkg/disk/lvm.go index 0a4035244d..5a8c8dbb1b 100644 --- a/pkg/disk/lvm.go +++ b/pkg/disk/lvm.go @@ -21,6 +21,8 @@ type LVMVolumeGroup struct { LogicalVolumes []LVMLogicalVolume `json:"logical_volumes,omitempty" yaml:"logical_volumes,omitempty"` } +var _ = MountpointCreator(&LVMVolumeGroup{}) + func init() { payloadEntityMap["lvm"] = reflect.TypeOf(LVMVolumeGroup{}) } @@ -73,10 +75,9 @@ func (vg *LVMVolumeGroup) GetChild(n uint) Entity { return &vg.LogicalVolumes[n] } -func (vg *LVMVolumeGroup) CreateMountpoint(mountpoint string, size uint64) (Entity, error) { - +func (vg *LVMVolumeGroup) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { filesystem := Filesystem{ - Type: "xfs", + Type: defaultFs, Mountpoint: mountpoint, FSTabOptions: "defaults", FSTabFreq: 0, diff --git a/pkg/disk/lvm_test.go b/pkg/disk/lvm_test.go index 8b0c3f419f..e52e9eb753 100644 --- a/pkg/disk/lvm_test.go +++ b/pkg/disk/lvm_test.go @@ -19,15 +19,15 @@ func TestLVMVCreateMountpoint(t *testing.T) { Description: "root volume group", } - entity, err := vg.CreateMountpoint("/", 0) + entity, err := vg.CreateMountpoint("/", "", 0) assert.NoError(err) rootlv := entity.(*LVMLogicalVolume) assert.Equal("rootlv", rootlv.Name) - _, err = vg.CreateMountpoint("/home_test", 0) + _, err = vg.CreateMountpoint("/home_test", "", 0) assert.NoError(err) - entity, err = vg.CreateMountpoint("/home/test", 0) + entity, err = vg.CreateMountpoint("/home/test", "", 0) assert.NoError(err) dedup := entity.(*LVMLogicalVolume) @@ -35,11 +35,11 @@ func TestLVMVCreateMountpoint(t *testing.T) { // Lets collide it for i := 0; i < 99; i++ { - _, err = vg.CreateMountpoint("/home/test", 0) + _, err = vg.CreateMountpoint("/home/test", "", 0) assert.NoError(err) } - _, err = vg.CreateMountpoint("/home/test", 0) + _, err = vg.CreateMountpoint("/home/test", "", 0) assert.Error(err) } diff --git a/pkg/disk/partition_table.go b/pkg/disk/partition_table.go index 4883a603f3..c37af08b80 100644 --- a/pkg/disk/partition_table.go +++ b/pkg/disk/partition_table.go @@ -32,6 +32,8 @@ type PartitionTable struct { StartOffset uint64 `json:"start_offset,omitempty" yaml:"start_offset,omitempty"` } +var _ = MountpointCreator(&PartitionTable{}) + // DefaultBootPartitionSize is the default size of the /boot partition if it // needs to be auto-created. This happens if the custom partitioning don't // specify one, but the image requires one to boot (/ is on btrfs, or an LV). @@ -90,15 +92,20 @@ const DefaultBootPartitionSize = 1 * datasizes.GiB // containing the root filesystem is grown to fill any left over space on the // partition table. Logical Volumes are not grown to fill the space in the // Volume Group since they are trivial to grow on a live system. -func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.FilesystemCustomization, imageSize uint64, mode partition.PartitioningMode, architecture arch.Arch, requiredSizes map[string]uint64, rng *rand.Rand) (*PartitionTable, error) { +func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.FilesystemCustomization, imageSize uint64, mode partition.PartitioningMode, architecture arch.Arch, requiredSizes map[string]uint64, defaultFs string, rng *rand.Rand) (*PartitionTable, error) { newPT := basePT.Clone().(*PartitionTable) if basePT.features().LVM && (mode == partition.RawPartitioningMode || mode == partition.BtrfsPartitioningMode) { return nil, fmt.Errorf("%s partitioning mode set for a base partition table with LVM, this is unsupported", mode) } + // compatibility with previous versions of images, if no + // default filesystem is given we pick "xfs" + if defaultFs == "" { + defaultFs = "xfs" + } // first pass: enlarge existing mountpoints and collect new ones - newMountpoints, _ := newPT.applyCustomization(mountpoints, false) + newMountpoints, _ := newPT.applyCustomization(mountpoints, defaultFs, false) var ensureLVM, ensureBtrfs bool switch mode { @@ -114,12 +121,12 @@ func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.Filesyste return nil, fmt.Errorf("unsupported partitioning mode %q", mode) } if ensureLVM { - err := newPT.ensureLVM() + err := newPT.ensureLVM(defaultFs) if err != nil { return nil, err } } else if ensureBtrfs { - err := newPT.ensureBtrfs(architecture) + err := newPT.ensureBtrfs(defaultFs, architecture) if err != nil { return nil, err } @@ -127,7 +134,7 @@ func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.Filesyste // second pass: deal with new mountpoints and newly created ones, after switching to // the LVM layout, if requested, which might introduce new mount points, i.e. `/boot` - _, err := newPT.applyCustomization(newMountpoints, true) + _, err := newPT.applyCustomization(newMountpoints, defaultFs, true) if err != nil { return nil, err } @@ -336,9 +343,9 @@ func (pt *PartitionTable) EnsureDirectorySizes(dirSizeMap map[string]uint64) { } } -func (pt *PartitionTable) CreateMountpoint(mountpoint string, size uint64) (Entity, error) { +func (pt *PartitionTable) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { filesystem := Filesystem{ - Type: "xfs", + Type: defaultFs, Mountpoint: mountpoint, FSTabOptions: "defaults", FSTabFreq: 0, @@ -437,7 +444,7 @@ func (pt *PartitionTable) HeaderSize() uint64 { // return a list of left-over mountpoints (i.e. mountpoints in the input that // were not created). An error can only occur if create is set. // Does not relayout the table, i.e. a call to relayout might be needed. -func (pt *PartitionTable) applyCustomization(mountpoints []blueprint.FilesystemCustomization, create bool) ([]blueprint.FilesystemCustomization, error) { +func (pt *PartitionTable) applyCustomization(mountpoints []blueprint.FilesystemCustomization, defaultFs string, create bool) ([]blueprint.FilesystemCustomization, error) { newMountpoints := []blueprint.FilesystemCustomization{} @@ -449,7 +456,7 @@ func (pt *PartitionTable) applyCustomization(mountpoints []blueprint.FilesystemC } else { if !create { newMountpoints = append(newMountpoints, mnt) - } else if err := pt.createFilesystem(mnt.Mountpoint, size); err != nil { + } else if err := pt.createFilesystem(mnt.Mountpoint, defaultFs, size); err != nil { return nil, err } } @@ -523,7 +530,7 @@ func (pt *PartitionTable) relayout(size uint64) uint64 { return start } -func (pt *PartitionTable) createFilesystem(mountpoint string, size uint64) error { +func (pt *PartitionTable) createFilesystem(mountpoint, defaultFs string, size uint64) error { rootPath := entityPath(pt, "/") if rootPath == nil { panic("no root mountpoint for PartitionTable") @@ -543,7 +550,7 @@ func (pt *PartitionTable) createFilesystem(mountpoint string, size uint64) error panic("could not find root volume container") } - newVol, err := vc.CreateMountpoint(mountpoint, 0) + newVol, err := vc.CreateMountpoint(mountpoint, defaultFs, 0) if err != nil { return fmt.Errorf("failed creating volume: %w", err) } @@ -722,7 +729,7 @@ func (pt *PartitionTable) GenUUID(rng *rand.Rand) { // ensureLVM will ensure that the root partition is on an LVM volume, i.e. if // it currently is not, it will wrap it in one -func (pt *PartitionTable) ensureLVM() error { +func (pt *PartitionTable) ensureLVM(defaultFS string) error { rootPath := entityPath(pt, "/") if rootPath == nil { @@ -732,7 +739,7 @@ func (pt *PartitionTable) ensureLVM() error { // we need a /boot partition to boot LVM, ensure one exists bootPath := entityPath(pt, "/boot") if bootPath == nil { - _, err := pt.CreateMountpoint("/boot", DefaultBootPartitionSize) + _, err := pt.CreateMountpoint("/boot", defaultFS, DefaultBootPartitionSize) if err != nil { return err @@ -781,7 +788,7 @@ func (pt *PartitionTable) ensureLVM() error { // ensureBtrfs will ensure that the root partition is on a btrfs subvolume, i.e. if // it currently is not, it will wrap it in one -func (pt *PartitionTable) ensureBtrfs(architecture arch.Arch) error { +func (pt *PartitionTable) ensureBtrfs(defaultFS string, architecture arch.Arch) error { rootPath := entityPath(pt, "/") if rootPath == nil { @@ -791,7 +798,7 @@ func (pt *PartitionTable) ensureBtrfs(architecture arch.Arch) error { // we need a /boot partition to boot btrfs, ensure one exists bootPath := entityPath(pt, "/boot") if bootPath == nil { - _, err := pt.CreateMountpoint("/boot", DefaultBootPartitionSize) + _, err := pt.CreateMountpoint("/boot", defaultFS, DefaultBootPartitionSize) if err != nil { return fmt.Errorf("failed to create /boot partition when ensuring btrfs: %w", err) } diff --git a/pkg/distro/bootc/partition.go b/pkg/distro/bootc/partition.go index 8e93add88e..477f2efbf8 100644 --- a/pkg/distro/bootc/partition.go +++ b/pkg/distro/bootc/partition.go @@ -169,7 +169,7 @@ func (t *BootcImageType) genPartitionTableFsCust(basept *disk.PartitionTable, fs } fsCustomizations := updateFilesystemSizes(fsCust, rootfsMinSize) - pt, err := disk.NewPartitionTable(basept, fsCustomizations, DEFAULT_SIZE, partitioningMode, t.arch.arch, nil, rng) + pt, err := disk.NewPartitionTable(basept, fsCustomizations, DEFAULT_SIZE, partitioningMode, t.arch.arch, nil, t.arch.distro.defaultFs, rng) if err != nil { return nil, err } diff --git a/pkg/distro/generic/imagetype.go b/pkg/distro/generic/imagetype.go index 82be375063..aaefd22c3d 100644 --- a/pkg/distro/generic/imagetype.go +++ b/pkg/distro/generic/imagetype.go @@ -163,6 +163,8 @@ func (t *imageType) getPartitionTable(customizations *blueprint.Customizations, if err != nil { return nil, err } + + defaultFsType := t.arch.distro.DefaultFSType if partitioning != nil { // Use the new custom partition table to create a PT fully based on the user's customizations. // This overrides FilesystemCustomizations, but we should never have both defined. @@ -175,7 +177,7 @@ func (t *imageType) getPartitionTable(customizations *blueprint.Customizations, partOptions := &disk.CustomPartitionTableOptions{ PartitionTableType: basePartitionTable.Type, // PT type is not customizable, it is determined by the base PT for an image type or architecture BootMode: t.BootMode(), - DefaultFSType: t.arch.distro.DefaultFSType, + DefaultFSType: defaultFsType, RequiredMinSizes: t.ImageTypeYAML.RequiredPartitionSizes, Architecture: t.platform.GetArch(), } @@ -183,7 +185,7 @@ func (t *imageType) getPartitionTable(customizations *blueprint.Customizations, } mountpoints := customizations.GetFilesystems() - return disk.NewPartitionTable(basePartitionTable, mountpoints, imageSize, options.PartitioningMode, t.platform.GetArch(), t.ImageTypeYAML.RequiredPartitionSizes, rng) + return disk.NewPartitionTable(basePartitionTable, mountpoints, imageSize, options.PartitioningMode, t.platform.GetArch(), t.ImageTypeYAML.RequiredPartitionSizes, defaultFsType.String(), rng) } func (t *imageType) getDefaultImageConfig() *distro.ImageConfig { diff --git a/pkg/osbuild/device_test.go b/pkg/osbuild/device_test.go index 770de2ea38..7ae50bbdef 100644 --- a/pkg/osbuild/device_test.go +++ b/pkg/osbuild/device_test.go @@ -24,7 +24,7 @@ func TestGenDeviceCreationStages(t *testing.T) { luks_lvm := testPartitionTables["luks+lvm"] - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_AARCH64, make(map[string]uint64), rng) + pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_AARCH64, make(map[string]uint64), "", rng) assert.NoError(err) stages := GenDeviceCreationStages(pt, "image.raw") @@ -87,7 +87,7 @@ func TestGenDeviceFinishStages(t *testing.T) { luks_lvm := testPartitionTables["luks+lvm"] - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_PPC64LE, make(map[string]uint64), rng) + pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_PPC64LE, make(map[string]uint64), "", rng) assert.NoError(err) stages := GenDeviceFinishStages(pt, "image.raw") @@ -130,7 +130,7 @@ func TestGenDeviceFinishStagesOrderWithLVMClevisBind(t *testing.T) { luks_lvm := testPartitionTables["luks+lvm+clevisBind"] - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_S390X, make(map[string]uint64), rng) + pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_S390X, make(map[string]uint64), "", rng) assert.NoError(err) stages := GenDeviceFinishStages(pt, "image.raw") diff --git a/pkg/osbuild/disk_test.go b/pkg/osbuild/disk_test.go index b4e678887f..573da4bb68 100644 --- a/pkg/osbuild/disk_test.go +++ b/pkg/osbuild/disk_test.go @@ -44,7 +44,7 @@ func TestGenImageKernelOptions(t *testing.T) { luks_lvm := testPartitionTables["luks+lvm"] - pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, make(map[string]uint64), rng) + pt, err := disk.NewPartitionTable(&luks_lvm, []blueprint.FilesystemCustomization{}, 0, partition.AutoLVMPartitioningMode, arch.ARCH_X86_64, make(map[string]uint64), "", rng) assert.NoError(err) uuids := collectUUIDs(pt) diff --git a/test/data/manifest-checksums/fedora_41-aarch64-server_ami-all_customizations b/test/data/manifest-checksums/fedora_41-aarch64-server_ami-all_customizations index 4200e86985..7b13a90f23 100644 --- a/test/data/manifest-checksums/fedora_41-aarch64-server_ami-all_customizations +++ b/test/data/manifest-checksums/fedora_41-aarch64-server_ami-all_customizations @@ -1 +1 @@ -62832f2923b9f5cceb800147dcd168bf311394c9 +1931ab842a6761f129f418c9671e48b2aa87029b diff --git a/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-all_with_fips index d24cae5e47..5609d931f3 100644 --- a/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-all_with_fips @@ -1 +1 @@ -da13820cdac2ca62c3c2aed3b1e310866b26c616 +d3c125832350fad6820dd01366e13d17633a4bf7 diff --git a/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-oscap_generic index 20545a69d7..9f2ac735d5 100644 --- a/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_41-aarch64-server_qcow2-oscap_generic @@ -1 +1 @@ -51bb4eb780a8a64e723068b221297fa67835226c +d095a056c21f20d0df6a78be97862a29f8ed8161 diff --git a/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-all_with_fips index f07952d782..78bb79a3d3 100644 --- a/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-all_with_fips @@ -1 +1 @@ -61d8d6fdb214342e27a7b23fab7db2c582199cfb +be1f77f59e71158a4e3f7e4b2a215d3340284e01 diff --git a/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-oscap_generic index 2c3513fd5c..23f7d77255 100644 --- a/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_41-ppc64le-server_qcow2-oscap_generic @@ -1 +1 @@ -610ada1af35164aedc23cf4f409f6d6d59f89087 +fa2fbf4790c817252c1bcce6344f3db423c1c32e diff --git a/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-all_with_fips index 8959f51089..421c36bb8b 100644 --- a/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-all_with_fips @@ -1 +1 @@ -c51ea9facc5f2fc721cdfde1479e2c5df4427c83 +8fbe193e819d31bf48706fb5b81831ed15d4524e diff --git a/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-oscap_generic index 5821f14f79..e601445845 100644 --- a/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_41-s390x-server_qcow2-oscap_generic @@ -1 +1 @@ -de81bb2c516dbe0fdd7f348ee7e3d9510e57c86b +2a75717e839031babfb75144be6d4244575655db diff --git a/test/data/manifest-checksums/fedora_41-x86_64-server_ami-all_customizations b/test/data/manifest-checksums/fedora_41-x86_64-server_ami-all_customizations index 37614fe256..f3e9a0fcf2 100644 --- a/test/data/manifest-checksums/fedora_41-x86_64-server_ami-all_customizations +++ b/test/data/manifest-checksums/fedora_41-x86_64-server_ami-all_customizations @@ -1 +1 @@ -e58e2cea3a72fe18d1d1b8c23d423e127404fa90 +0d3c2d308a2ac6a4de380a9ac36f24f0dfc3e586 diff --git a/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-all_with_fips index a5856eef75..4559964242 100644 --- a/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-all_with_fips @@ -1 +1 @@ -6180489483128417b375dd45d34c74264608308b +41348e8190dde490e74e00b1d3502e0fea3dfb55 diff --git a/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-oscap_generic index 31e1f6286c..b9ee8f8ee4 100644 --- a/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_41-x86_64-server_qcow2-oscap_generic @@ -1 +1 @@ -c7826f0d281c9e978c77f24b31548a5aa59be00f +9933a14ab174ce80b9191786ce2863673b065bb6 diff --git a/test/data/manifest-checksums/fedora_42-aarch64-server_ami-all_customizations b/test/data/manifest-checksums/fedora_42-aarch64-server_ami-all_customizations index c2553f46f2..573cdf6db9 100644 --- a/test/data/manifest-checksums/fedora_42-aarch64-server_ami-all_customizations +++ b/test/data/manifest-checksums/fedora_42-aarch64-server_ami-all_customizations @@ -1 +1 @@ -d2c1a52efadbabf1a0963099a758d72cf2fa061f +d85493dd5f33a3a6437384e82f3b18cbdf78a1d5 diff --git a/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-all_with_fips index 5766686149..1a98d9c17e 100644 --- a/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-all_with_fips @@ -1 +1 @@ -459338d177664c9e77eb18c8f1e02d1f707b81d9 +69b43cb8f2276b422a3aa8c4c298f27c643b345e diff --git a/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-oscap_generic index 696827a3b1..f61f7f7159 100644 --- a/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_42-aarch64-server_qcow2-oscap_generic @@ -1 +1 @@ -c844d09ad719b0eb2b20a666b9c456e55c48525a +3001bbb50fd6d351389aef1134d762ab7fa00187 diff --git a/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-all_with_fips index bf68011c7b..fc608f3499 100644 --- a/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-all_with_fips @@ -1 +1 @@ -a76c09ecdc37995f92c7705977f7e147e7456bb0 +99b9d19707add917c713beb138b604ef0a32c468 diff --git a/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-oscap_generic index 3128ecbfc7..ea97bbc118 100644 --- a/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_42-ppc64le-server_qcow2-oscap_generic @@ -1 +1 @@ -51a5c8d0b6c17725cdc650f555312201e002f0c4 +db76a5aab140573c10c4655cbabf1318c183fda7 diff --git a/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-all_with_fips index 7a13331a35..2e62f5df9e 100644 --- a/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-all_with_fips @@ -1 +1 @@ -afe0a72eedee9eab448a8a26124a3f00da31ed3d +a9a87542d02f148ac7d20379e0cf649544170369 diff --git a/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-oscap_generic index b2ed08d9b1..b2fd714680 100644 --- a/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_42-s390x-server_qcow2-oscap_generic @@ -1 +1 @@ -09f4bd6c8cc0a3d631b2e8b3895e8481e5745ce2 +b94a0098917ef47fa5b6c66305365b335f0d3778 diff --git a/test/data/manifest-checksums/fedora_42-x86_64-server_ami-all_customizations b/test/data/manifest-checksums/fedora_42-x86_64-server_ami-all_customizations index 496623f764..6e909c3c5d 100644 --- a/test/data/manifest-checksums/fedora_42-x86_64-server_ami-all_customizations +++ b/test/data/manifest-checksums/fedora_42-x86_64-server_ami-all_customizations @@ -1 +1 @@ -62de36ef37663beeefd8c264d2fd35314ec5e3a8 +ff7c59d5d8ebc05af7af51630ea1f0325eacf415 diff --git a/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-all_with_fips index a7b9eee81c..372f582ca9 100644 --- a/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-all_with_fips @@ -1 +1 @@ -2f965930f0764dc0ca3d6baf5fa8260bd490ae76 +27f8ecfb3ef8f6acc20a37acb62fd8b722e21535 diff --git a/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-oscap_generic index eb46483194..24c7bd097c 100644 --- a/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_42-x86_64-server_qcow2-oscap_generic @@ -1 +1 @@ -4a5a5f8011352b25e353b72ab8f13d9c31c07dcc +7b5394231a4bf4547cfee75f452c394d5f99eeb3 diff --git a/test/data/manifest-checksums/fedora_43-aarch64-server_ami-all_customizations b/test/data/manifest-checksums/fedora_43-aarch64-server_ami-all_customizations index 68d4a7284f..dc0f8fe03b 100644 --- a/test/data/manifest-checksums/fedora_43-aarch64-server_ami-all_customizations +++ b/test/data/manifest-checksums/fedora_43-aarch64-server_ami-all_customizations @@ -1 +1 @@ -2589c23a9e7310f38a932fb9c066fa1a342b9d12 +4c35a101d192847b2375d572726805455b140291 diff --git a/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-all_with_fips index 20735fa17d..45d758df62 100644 --- a/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-all_with_fips @@ -1 +1 @@ -879743b501f47df69d327ae8208e540eaf32c1a8 +056e36812ca545714d231ff6850c6dac4f607442 diff --git a/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-oscap_generic index babcb97f20..0e3c95f57d 100644 --- a/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_43-aarch64-server_qcow2-oscap_generic @@ -1 +1 @@ -068a8edf1a86b7456e58912c179b5d94fa09bc8a +40b9c5b3e1831efbbe53d7dd16b1a663c086f5b5 diff --git a/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-all_with_fips index ab04b2bef9..5622f63c01 100644 --- a/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-all_with_fips @@ -1 +1 @@ -b4890f0182104383b959bb9e1409d59185e2437b +4ebcfa68215e62d8459f28e530ebd8cc415ed099 diff --git a/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-oscap_generic index cc07cb72e2..5d0ff644fe 100644 --- a/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_43-ppc64le-server_qcow2-oscap_generic @@ -1 +1 @@ -12c5b70c517ccada3397d594e67daeb0ad466b12 +9e94615686131f87f34222d00340d2a215d3e565 diff --git a/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-all_with_fips index 24052f1ccd..fc4dd3ce4d 100644 --- a/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-all_with_fips @@ -1 +1 @@ -c112d14c1a04e103b81995cd6c9f837746b60887 +410d4df37038fa23d315e108257fa931ba599f33 diff --git a/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-oscap_generic index 2d4d2f17ea..fa4b9f2420 100644 --- a/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_43-s390x-server_qcow2-oscap_generic @@ -1 +1 @@ -a46c4290a3f56a5f412d84f48322cadbea98e479 +104cc1ba30f70e3d676e689adfada1b7ca7d0cf8 diff --git a/test/data/manifest-checksums/fedora_43-x86_64-server_ami-all_customizations b/test/data/manifest-checksums/fedora_43-x86_64-server_ami-all_customizations index 7254cce983..264af47bf4 100644 --- a/test/data/manifest-checksums/fedora_43-x86_64-server_ami-all_customizations +++ b/test/data/manifest-checksums/fedora_43-x86_64-server_ami-all_customizations @@ -1 +1 @@ -2fe37625d759482faeea52bb8082c8d354d321f3 +f25c3de72e60bb642ef4b42c1f81ae08ee80b0fc diff --git a/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-all_with_fips b/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-all_with_fips index 8c3016ea29..bc08cf0ac7 100644 --- a/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-all_with_fips +++ b/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-all_with_fips @@ -1 +1 @@ -43f2d4f7ebbbfc751c914a8d8ca15d91df43f584 +226d87b9d8b3b4e09002fb7296ca21a36fe9035d diff --git a/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-oscap_generic b/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-oscap_generic index eee17392a7..0b83cd20b5 100644 --- a/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-oscap_generic +++ b/test/data/manifest-checksums/fedora_43-x86_64-server_qcow2-oscap_generic @@ -1 +1 @@ -a5973c3bee603e7ed13d4ccae6752f8752df84d7 +ab9e8d96a91b81de94024106ee5958f75cddfaba From 4175866f5531e63307cd8d84accf26603aba30fb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Sep 2025 16:53:27 +0200 Subject: [PATCH 2/2] disk: error is CreateMountpoint is called with the wrong fs This implements the suggestion by Achilleas to error when CreateMointpoint() in btrfs or lvm is called with the wrong arguments, see https://github.com/osbuild/images/pull/1714#discussion_r2247334457 Thanks to Achilleas. --- pkg/disk/btrfs.go | 4 ++++ pkg/disk/disk_test.go | 3 +++ pkg/disk/lvm.go | 4 ++++ pkg/disk/partition_table.go | 1 + 4 files changed, 12 insertions(+) diff --git a/pkg/disk/btrfs.go b/pkg/disk/btrfs.go index 2b360b39cc..b71f123271 100644 --- a/pkg/disk/btrfs.go +++ b/pkg/disk/btrfs.go @@ -61,6 +61,10 @@ func (b *Btrfs) GetChild(n uint) Entity { return &b.Subvolumes[n] } func (b *Btrfs) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { + if defaultFs != "btrfs" { + return nil, fmt.Errorf("only btrfs mountpoints are supported with btrfs subvolumes not %q", defaultFs) + } + name := mountpoint if name == "/" { name = "root" diff --git a/pkg/disk/disk_test.go b/pkg/disk/disk_test.go index cb00b039ca..009dccb2dc 100644 --- a/pkg/disk/disk_test.go +++ b/pkg/disk/disk_test.go @@ -194,6 +194,9 @@ func TestCreatePartitionTable(t *testing.T) { if ptName == "luks+lvm" { ptMode = partition.AutoLVMPartitioningMode } + if ptName == "btrfs" { + ptMode = partition.BtrfsPartitioningMode + } mpt, err := disk.NewPartitionTable(&pt, bp, uint64(13*MiB), ptMode, arch.ARCH_PPC64LE, nil, "", rng) require.NoError(t, err, "Partition table generation failed: PT %q BP %q (%s)", ptName, bpName, err) assert.NotNil(mpt, "Partition table generation failed: PT %q BP %q (nil partition table)", ptName, bpName) diff --git a/pkg/disk/lvm.go b/pkg/disk/lvm.go index 5a8c8dbb1b..8cf1e85841 100644 --- a/pkg/disk/lvm.go +++ b/pkg/disk/lvm.go @@ -76,6 +76,10 @@ func (vg *LVMVolumeGroup) GetChild(n uint) Entity { } func (vg *LVMVolumeGroup) CreateMountpoint(mountpoint, defaultFs string, size uint64) (Entity, error) { + if defaultFs == "btrfs" { + return nil, fmt.Errorf("btrfs under lvm is not supported") + } + filesystem := Filesystem{ Type: defaultFs, Mountpoint: mountpoint, diff --git a/pkg/disk/partition_table.go b/pkg/disk/partition_table.go index c37af08b80..314dd1a868 100644 --- a/pkg/disk/partition_table.go +++ b/pkg/disk/partition_table.go @@ -117,6 +117,7 @@ func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.Filesyste ensureLVM = len(newMountpoints) > 0 case partition.BtrfsPartitioningMode: ensureBtrfs = true + defaultFs = "btrfs" default: return nil, fmt.Errorf("unsupported partitioning mode %q", mode) }