distro: rhel85 declarative partition tables
This commit is contained in:
parent
e21eee273c
commit
280e1b6e3d
5 changed files with 347 additions and 219 deletions
|
|
@ -26,47 +26,24 @@ const (
|
|||
|
||||
func CreatePartitionTable(
|
||||
mountpoints []blueprint.FilesystemCustomization,
|
||||
imageOptions distro.ImageOptions,
|
||||
arch distro.Arch,
|
||||
imageSize uint64,
|
||||
basePartitionTable PartitionTable,
|
||||
bootType distro.BootType,
|
||||
ec2 bool,
|
||||
rng *rand.Rand,
|
||||
) PartitionTable {
|
||||
archName := arch.Name()
|
||||
|
||||
basePartitionTable.Size = imageOptions.Size
|
||||
basePartitionTable.Size = imageSize
|
||||
partitions := []Partition{}
|
||||
var start uint64 = 2048
|
||||
|
||||
if archName == distro.X86_64ArchName {
|
||||
biosBootPartition := createPartition("bios", 2048, start, archName, rng)
|
||||
partitions = append(partitions, biosBootPartition)
|
||||
start += biosBootPartition.Size
|
||||
if bootType != distro.LegacyBootType {
|
||||
bootEFIPartition := createPartition("/boot/efi", 204800, start, archName, rng)
|
||||
partitions = append(partitions, bootEFIPartition)
|
||||
start += bootEFIPartition.Size
|
||||
}
|
||||
} else if archName == distro.Aarch64ArchName {
|
||||
if ec2 {
|
||||
bootEFIParition := createPartition("/boot/efi", 409600, start, archName, rng)
|
||||
partitions = append(partitions, bootEFIParition)
|
||||
start += bootEFIParition.Size
|
||||
bootPartition := createPartition("/boot", 1048576, start, archName, rng)
|
||||
partitions = append(partitions, bootPartition)
|
||||
start += bootPartition.Size
|
||||
} else {
|
||||
bootEFIPartition := createPartition("/boot/efi", 204800, start, archName, rng)
|
||||
partitions = append(partitions, bootEFIPartition)
|
||||
start += bootEFIPartition.Size
|
||||
}
|
||||
} else if archName == distro.Ppc64leArchName {
|
||||
biosBootPartition := createPartition("bios", 8192, start, archName, rng)
|
||||
partitions = append(partitions, biosBootPartition)
|
||||
start += biosBootPartition.Size
|
||||
if bootPartition := basePartitionTable.BootPartition(); bootPartition != nil {
|
||||
// the boot partition UUID needs to be set since this
|
||||
// needs to be randomly generated
|
||||
bootPartition.Filesystem.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String()
|
||||
}
|
||||
|
||||
// start point for all of the arches is
|
||||
// 2048 sectors.
|
||||
var start uint64 = basePartitionTable.updatePartitionStartPointOffsets(2048)
|
||||
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint != "/" {
|
||||
partitionSize := uint64(m.MinSize) / sectorSize
|
||||
|
|
@ -77,94 +54,41 @@ func CreatePartitionTable(
|
|||
}
|
||||
|
||||
// treat the root partition as a special case
|
||||
// by setting it last and setting the size
|
||||
// dynamically
|
||||
rootSize := (imageOptions.Size / sectorSize) - start - 100
|
||||
rootPartition := createPartition("/", rootSize, start, archName, rng)
|
||||
partitions = append(partitions, rootPartition)
|
||||
// by setting the size dynamically
|
||||
rootPartition := basePartitionTable.RootPartition()
|
||||
rootPartition.Start = start
|
||||
rootPartition.Size = ((imageSize / sectorSize) - start - 100)
|
||||
rootPartition.Filesystem.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String()
|
||||
|
||||
basePartitionTable.updateRootPartition(*rootPartition)
|
||||
basePartitionTable.Partitions = append(basePartitionTable.Partitions, partitions...)
|
||||
|
||||
return basePartitionTable
|
||||
}
|
||||
|
||||
func createPartition(mountpoint string, size uint64, start uint64, archName string, rng *rand.Rand) Partition {
|
||||
if mountpoint == "bios" {
|
||||
diskPartition := Partition{
|
||||
Start: start,
|
||||
Size: size,
|
||||
Bootable: true,
|
||||
}
|
||||
if archName == distro.X86_64ArchName {
|
||||
diskPartition.Type = BIOSBootPartitionGUID
|
||||
diskPartition.UUID = BIOSBootPartitionUUID
|
||||
return diskPartition
|
||||
}
|
||||
diskPartition.Type = "41"
|
||||
return diskPartition
|
||||
}
|
||||
var filesystem Filesystem
|
||||
// EFI system is a special case
|
||||
// return early
|
||||
if mountpoint == "/boot/efi" {
|
||||
filesystem = createFilesystemDisk(mountpoint, EFIFilesystemUUID)
|
||||
return Partition{
|
||||
Start: start,
|
||||
Size: size,
|
||||
Type: EFISystemPartitionGUID,
|
||||
UUID: EFISystemPartitionUUID,
|
||||
Filesystem: &filesystem,
|
||||
}
|
||||
}
|
||||
partition := Partition{
|
||||
Start: start,
|
||||
Size: size,
|
||||
Filesystem: &filesystem,
|
||||
}
|
||||
diskUUID := uuid.Must(newRandomUUIDFromReader(rng)).String()
|
||||
filesystem = createFilesystemDisk(mountpoint, diskUUID)
|
||||
if mountpoint == "/boot" {
|
||||
partition.Type = FilesystemDataGUID
|
||||
partition.UUID = FilesystemDataUUID
|
||||
return partition
|
||||
}
|
||||
if archName == distro.X86_64ArchName || archName == distro.Aarch64ArchName {
|
||||
if mountpoint == "/" {
|
||||
// set Label for root mountpoint
|
||||
filesystem.Label = "root"
|
||||
partition.Type = FilesystemDataGUID
|
||||
partition.UUID = RootPartitionUUID
|
||||
return partition
|
||||
}
|
||||
partition.Type = FilesystemDataGUID
|
||||
partition.UUID = uuid.Must(newRandomUUIDFromReader(rng)).String()
|
||||
return partition
|
||||
}
|
||||
if mountpoint == "/" && archName == distro.S390xArchName {
|
||||
partition.Bootable = true
|
||||
}
|
||||
return partition
|
||||
}
|
||||
|
||||
func createFilesystemDisk(mountpoint string, uuid string) Filesystem {
|
||||
if mountpoint == "/boot/efi" {
|
||||
return Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: uuid,
|
||||
Mountpoint: mountpoint,
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
}
|
||||
}
|
||||
return Filesystem{
|
||||
filesystem := Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid,
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Mountpoint: mountpoint,
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
}
|
||||
if archName == distro.Ppc64leArchName || archName == distro.S390xArchName {
|
||||
return Partition{
|
||||
Start: start,
|
||||
Size: size,
|
||||
Filesystem: &filesystem,
|
||||
}
|
||||
}
|
||||
return Partition{
|
||||
Start: start,
|
||||
Size: size,
|
||||
Type: FilesystemDataGUID,
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
Filesystem: &filesystem,
|
||||
}
|
||||
}
|
||||
|
||||
func newRandomUUIDFromReader(r io.Reader) (uuid.UUID, error) {
|
||||
|
|
|
|||
|
|
@ -157,6 +157,38 @@ func (pt PartitionTable) BootPartitionIndex() int {
|
|||
return rootIdx
|
||||
}
|
||||
|
||||
func (pt PartitionTable) RootPartitionIndex() int {
|
||||
rootIdx := -1
|
||||
for idx, part := range pt.Partitions {
|
||||
if part.Filesystem == nil {
|
||||
continue
|
||||
}
|
||||
if part.Filesystem.Mountpoint == "/" {
|
||||
rootIdx = idx
|
||||
}
|
||||
}
|
||||
return rootIdx
|
||||
}
|
||||
|
||||
// dynamically calculate and update the start point
|
||||
// for each of the existing partitions
|
||||
// return the updated start point
|
||||
func (pt *PartitionTable) updatePartitionStartPointOffsets(start uint64) uint64 {
|
||||
for i := range pt.Partitions {
|
||||
partition := &pt.Partitions[i]
|
||||
if partition.Filesystem != nil && partition.Filesystem.Mountpoint == "/" {
|
||||
continue
|
||||
}
|
||||
partition.Start = start
|
||||
start += partition.Size
|
||||
}
|
||||
return start
|
||||
}
|
||||
|
||||
func (pt *PartitionTable) updateRootPartition(rootPartition Partition) {
|
||||
pt.Partitions[pt.RootPartitionIndex()] = rootPartition
|
||||
}
|
||||
|
||||
// Converts Partition to osbuild.QEMUPartition that encodes the same partition.
|
||||
func (p Partition) QEMUPartition() osbuild.QEMUPartition {
|
||||
var fs *osbuild.QEMUFilesystem
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ const (
|
|||
blueprintPkgsKey = "blueprint"
|
||||
)
|
||||
|
||||
type ValidArches map[string]disk.PartitionTable
|
||||
type basePartitionTableMap map[string]disk.PartitionTable
|
||||
|
||||
var mountpointAllowList = []string{"/", "/var", "/var/*", "/home", "/opt", "/srv", "/usr"}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ type imageType struct {
|
|||
// If set to a value, it is preferred over the architecture value
|
||||
bootType distro.BootType
|
||||
// List of valid arches for the image type
|
||||
validArches ValidArches
|
||||
basePartitionTables basePartitionTableMap
|
||||
}
|
||||
|
||||
func (t *imageType) Name() string {
|
||||
|
|
@ -333,6 +333,22 @@ func (t *imageType) supportsUEFI() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (t *imageType) getPartitionTable(
|
||||
mountpoints []blueprint.FilesystemCustomization,
|
||||
options distro.ImageOptions,
|
||||
rng *rand.Rand,
|
||||
) (disk.PartitionTable, error) {
|
||||
archName := t.arch.Name()
|
||||
|
||||
basePartitionTable, exists := t.basePartitionTables[archName]
|
||||
|
||||
if !exists {
|
||||
return basePartitionTable, fmt.Errorf("unknown arch: " + archName)
|
||||
}
|
||||
|
||||
return disk.CreatePartitionTable(mountpoints, options.Size, basePartitionTable, rng), nil
|
||||
}
|
||||
|
||||
// local type for ostree commit metadata used to define commit sources
|
||||
type ostreeCommit struct {
|
||||
Checksum string
|
||||
|
|
@ -597,11 +613,11 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
packageSets: map[string]rpmmd.PackageSet{
|
||||
osPkgsKey: qcow2CommonPackageSet(),
|
||||
},
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
exports: []string{"qcow2"},
|
||||
validArches: defaultArches,
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: qcow2Pipelines,
|
||||
exports: []string{"qcow2"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
vhdImgType := imageType{
|
||||
|
|
@ -615,13 +631,13 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
"sshd",
|
||||
"waagent",
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: vhdPipelines,
|
||||
exports: []string{"vpc"},
|
||||
validArches: defaultArches,
|
||||
defaultTarget: "multi-user.target",
|
||||
kernelOptions: "ro biosdevname=0 rootdelay=300 console=ttyS0 earlyprintk=ttyS0 net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: vhdPipelines,
|
||||
exports: []string{"vpc"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
vmdkImgType := imageType{
|
||||
|
|
@ -631,12 +647,12 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
packageSets: map[string]rpmmd.PackageSet{
|
||||
osPkgsKey: vmdkCommonPackageSet(),
|
||||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: vmdkPipelines,
|
||||
exports: []string{"vmdk"},
|
||||
validArches: defaultArches,
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: vmdkPipelines,
|
||||
exports: []string{"vmdk"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
openstackImgType := imageType{
|
||||
|
|
@ -646,12 +662,12 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
packageSets: map[string]rpmmd.PackageSet{
|
||||
osPkgsKey: openstackCommonPackageSet(),
|
||||
},
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: openstackPipelines,
|
||||
exports: []string{"qcow2"},
|
||||
validArches: defaultArches,
|
||||
kernelOptions: "ro net.ifnames=0",
|
||||
bootable: true,
|
||||
defaultSize: 4 * GigaByte,
|
||||
pipelines: openstackPipelines,
|
||||
exports: []string{"qcow2"},
|
||||
basePartitionTables: defaultBasePartitionTables,
|
||||
}
|
||||
|
||||
// EC2 services
|
||||
|
|
@ -675,15 +691,15 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
buildPkgsKey: ec2BuildPackageSet(),
|
||||
osPkgsKey: ec2CommonPackageSet(),
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
validArches: ec2ValidArches,
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
amiImgTypeAarch64 := imageType{
|
||||
|
|
@ -694,14 +710,14 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
buildPkgsKey: ec2BuildPackageSet(),
|
||||
osPkgsKey: ec2CommonPackageSet(),
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
validArches: ec2ValidArches,
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: ec2Pipelines,
|
||||
exports: []string{"image"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
ec2ImgTypeX86_64 := imageType{
|
||||
|
|
@ -712,15 +728,15 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
buildPkgsKey: ec2BuildPackageSet(),
|
||||
osPkgsKey: rhelEc2PackageSet(),
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
validArches: ec2ValidArches,
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
ec2ImgTypeAarch64 := imageType{
|
||||
|
|
@ -731,14 +747,14 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
buildPkgsKey: ec2BuildPackageSet(),
|
||||
osPkgsKey: rhelEc2PackageSet(),
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
validArches: ec2ValidArches,
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 iommu.strict=0 crashkernel=auto",
|
||||
bootable: true,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
ec2HaImgTypeX86_64 := imageType{
|
||||
|
|
@ -749,15 +765,15 @@ func newDistro(name, modulePlatformID, ostreeRef string) distro.Distro {
|
|||
buildPkgsKey: ec2BuildPackageSet(),
|
||||
osPkgsKey: rhelEc2HaPackageSet(),
|
||||
},
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
validArches: ec2ValidArches,
|
||||
defaultTarget: "multi-user.target",
|
||||
enabledServices: ec2EnabledServices,
|
||||
kernelOptions: "console=ttyS0,115200n8 console=tty0 net.ifnames=0 rd.blacklist=nouveau nvme_core.io_timeout=4294967295 crashkernel=auto",
|
||||
bootable: true,
|
||||
bootType: distro.LegacyBootType,
|
||||
defaultSize: 10 * GigaByte,
|
||||
pipelines: rhelEc2Pipelines,
|
||||
exports: []string{"archive"},
|
||||
basePartitionTables: ec2BasePartitionTables,
|
||||
}
|
||||
|
||||
tarImgType := imageType{
|
||||
|
|
|
|||
|
|
@ -5,37 +5,179 @@ import (
|
|||
"github.com/osbuild/osbuild-composer/internal/distro"
|
||||
)
|
||||
|
||||
var defaultArches = map[string]disk.PartitionTable{
|
||||
distro.X86_64ArchName: gptPartitionTable,
|
||||
distro.Aarch64ArchName: gptPartitionTable,
|
||||
distro.Ppc64leArchName: dosPartitionTable,
|
||||
distro.S390xArchName: dosPartitionTable,
|
||||
var defaultBasePartitionTables = basePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 2048,
|
||||
Bootable: true,
|
||||
Type: disk.BIOSBootPartitionGUID,
|
||||
UUID: disk.BIOSBootPartitionUUID,
|
||||
},
|
||||
{
|
||||
Size: 204800,
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Aarch64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 204800,
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Ppc64leArchName: disk.PartitionTable{
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 8192,
|
||||
Type: "41",
|
||||
Bootable: true,
|
||||
},
|
||||
{
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.S390xArchName: disk.PartitionTable{
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Bootable: true,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var ec2ValidArches = map[string]disk.PartitionTable{
|
||||
distro.X86_64ArchName: gptPartitionTable,
|
||||
distro.Aarch64ArchName: gptPartitionTable,
|
||||
}
|
||||
|
||||
var gptPartitionTable = disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{},
|
||||
}
|
||||
|
||||
var dosPartitionTable = disk.PartitionTable{
|
||||
UUID: "0x14fc63d2",
|
||||
Type: "dos",
|
||||
Partitions: []disk.Partition{},
|
||||
}
|
||||
|
||||
func getBasePartitionTable(arch distro.Arch, validArches ValidArches) disk.PartitionTable {
|
||||
archName := arch.Name()
|
||||
partitionTable, ok := validArches[archName]
|
||||
|
||||
if !ok {
|
||||
panic("unknown arch: " + archName)
|
||||
}
|
||||
|
||||
return partitionTable
|
||||
var ec2BasePartitionTables = basePartitionTableMap{
|
||||
distro.X86_64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 2048,
|
||||
Bootable: true,
|
||||
Type: disk.BIOSBootPartitionGUID,
|
||||
UUID: disk.BIOSBootPartitionUUID,
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
distro.Aarch64ArchName: disk.PartitionTable{
|
||||
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
||||
Type: "gpt",
|
||||
Partitions: []disk.Partition{
|
||||
{
|
||||
Size: 409600,
|
||||
Type: disk.EFISystemPartitionGUID,
|
||||
UUID: disk.EFISystemPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "vfat",
|
||||
UUID: disk.EFIFilesystemUUID,
|
||||
Mountpoint: "/boot/efi",
|
||||
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Size: 1048576,
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.FilesystemDataUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Mountpoint: "/boot",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: disk.FilesystemDataGUID,
|
||||
UUID: disk.RootPartitionUUID,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
Label: "root",
|
||||
Mountpoint: "/",
|
||||
FSTabOptions: "defaults",
|
||||
FSTabFreq: 0,
|
||||
FSTabPassNo: 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,11 @@ func qcow2Pipelines(t *imageType, customizations *blueprint.Customizations, opti
|
|||
return nil, err
|
||||
}
|
||||
|
||||
basePartitionTable := getBasePartitionTable(t.Arch(), t.validArches)
|
||||
partitionTable := disk.CreatePartitionTable(customizations.GetFilesystems(), options, t.Arch(), basePartitionTable, t.bootType, false, rng)
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
treePipeline = prependKernelCmdlineStage(treePipeline, t, &partitionTable)
|
||||
|
||||
if options.Subscription == nil {
|
||||
|
|
@ -77,8 +80,11 @@ func vhdPipelines(t *imageType, customizations *blueprint.Customizations, option
|
|||
return nil, err
|
||||
}
|
||||
|
||||
basePartitionTable := getBasePartitionTable(t.Arch(), t.validArches)
|
||||
partitionTable := disk.CreatePartitionTable(customizations.GetFilesystems(), options, t.Arch(), basePartitionTable, t.bootType, false, rng)
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
|
||||
kernelVer := kernelVerStr(packageSetSpecs[blueprintPkgsKey], customizations.GetKernel().Name, t.Arch().Name())
|
||||
treePipeline.AddStage(bootloaderConfigStage(t, partitionTable, customizations.GetKernel(), kernelVer))
|
||||
|
|
@ -105,8 +111,11 @@ func vmdkPipelines(t *imageType, customizations *blueprint.Customizations, optio
|
|||
return nil, err
|
||||
}
|
||||
|
||||
basePartitionTable := getBasePartitionTable(t.Arch(), t.validArches)
|
||||
partitionTable := disk.CreatePartitionTable(customizations.GetFilesystems(), options, t.Arch(), basePartitionTable, t.bootType, false, rng)
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
|
||||
kernelVer := kernelVerStr(packageSetSpecs[blueprintPkgsKey], customizations.GetKernel().Name, t.Arch().Name())
|
||||
treePipeline.AddStage(bootloaderConfigStage(t, partitionTable, customizations.GetKernel(), kernelVer))
|
||||
|
|
@ -133,8 +142,11 @@ func openstackPipelines(t *imageType, customizations *blueprint.Customizations,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
basePartitionTable := getBasePartitionTable(t.Arch(), t.validArches)
|
||||
partitionTable := disk.CreatePartitionTable(customizations.GetFilesystems(), options, t.Arch(), basePartitionTable, t.bootType, false, rng)
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
treePipeline.AddStage(osbuild.NewFSTabStage(partitionTable.FSTabStageOptionsV2()))
|
||||
kernelVer := kernelVerStr(packageSetSpecs[blueprintPkgsKey], customizations.GetKernel().Name, t.Arch().Name())
|
||||
treePipeline.AddStage(bootloaderConfigStage(t, partitionTable, customizations.GetKernel(), kernelVer))
|
||||
|
|
@ -396,10 +408,12 @@ func ec2CommonPipelines(t *imageType, customizations *blueprint.Customizations,
|
|||
pipelines := make([]osbuild.Pipeline, 0)
|
||||
pipelines = append(pipelines, *buildPipeline(repos, packageSetSpecs[buildPkgsKey]))
|
||||
|
||||
basePartitionTable := getBasePartitionTable(t.Arch(), t.validArches)
|
||||
partitionTable := disk.CreatePartitionTable(customizations.GetFilesystems(), options, t.Arch(), basePartitionTable, t.bootType, true, rng)
|
||||
partitionTable, err := t.getPartitionTable(customizations.GetFilesystems(), options, rng)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var treePipeline *osbuild.Pipeline
|
||||
var err error
|
||||
switch arch := t.arch.Name(); arch {
|
||||
// rhel-ec2-x86_64, rhel-ha-ec2
|
||||
case distro.X86_64ArchName:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue