distro/rhel85: partition table fixes
- Automatically find /boot partition (fallback to root) - Partition sizes need a bit of a shrink
This commit is contained in:
parent
cd030c0bd6
commit
78920efc36
3 changed files with 25 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func defaultPartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, rng *rand.Rand) disk.PartitionTable {
|
||||
var sectorSize uint64 = 512
|
||||
if arch.Name() == "x86_64" {
|
||||
return disk.PartitionTable{
|
||||
Size: imageOptions.Size,
|
||||
|
|
@ -39,6 +40,7 @@ func defaultPartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, r
|
|||
},
|
||||
{
|
||||
Start: 208896,
|
||||
Size: imageOptions.Size/sectorSize - 208896 - 100,
|
||||
Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
|
||||
UUID: "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
|
||||
Filesystem: &disk.Filesystem{
|
||||
|
|
@ -75,6 +77,7 @@ func defaultPartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, r
|
|||
},
|
||||
{
|
||||
Start: 206848,
|
||||
Size: imageOptions.Size/sectorSize - 206848 - 100,
|
||||
Type: "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
|
||||
UUID: "6264D520-3FB9-423F-8AB8-7A0A8E3D3562",
|
||||
Filesystem: &disk.Filesystem{
|
||||
|
|
@ -102,6 +105,7 @@ func defaultPartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, r
|
|||
},
|
||||
{
|
||||
Start: 10240,
|
||||
Size: imageOptions.Size/sectorSize - 10240 - 100,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
UUID: uuid.Must(newRandomUUIDFromReader(rng)).String(),
|
||||
|
|
@ -121,6 +125,7 @@ func defaultPartitionTable(imageOptions distro.ImageOptions, arch distro.Arch, r
|
|||
Partitions: []disk.Partition{
|
||||
{
|
||||
Start: 2048,
|
||||
Size: imageOptions.Size/sectorSize - 2048 - 100,
|
||||
Bootable: true,
|
||||
Filesystem: &disk.Filesystem{
|
||||
Type: "xfs",
|
||||
|
|
|
|||
|
|
@ -626,7 +626,7 @@ func liveImagePipeline(inputPipelineName string, outputFilename string, pt *disk
|
|||
copyInputs := copyPipelineTreeInputs(inputName, inputPipelineName)
|
||||
p.AddStage(osbuild.NewCopyStage(copyOptions, copyInputs, copyDevices, copyMounts))
|
||||
|
||||
p.AddStage(osbuild.NewGrub2InstStage(grub2InstStageOptions(outputFilename, pt, 2, platform)))
|
||||
p.AddStage(osbuild.NewGrub2InstStage(grub2InstStageOptions(outputFilename, pt, platform)))
|
||||
|
||||
return p
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,6 +465,25 @@ func grub2InstStageOptions(filename string, pt *disk.PartitionTable, platform st
|
|||
}
|
||||
}
|
||||
|
||||
func findBootPartition(pt *disk.PartitionTable) uint {
|
||||
// find partition with '/boot' mountpoint and fallback to '/'
|
||||
rootIdx := -1
|
||||
for idx, part := range pt.Partitions {
|
||||
if part.Filesystem == nil {
|
||||
continue
|
||||
}
|
||||
if part.Filesystem.Mountpoint == "/boot" {
|
||||
return uint(idx)
|
||||
} else if part.Filesystem.Mountpoint == "/" {
|
||||
rootIdx = idx
|
||||
}
|
||||
}
|
||||
if rootIdx == -1 {
|
||||
panic("failed to find boot or root partition for grub2.inst stage")
|
||||
}
|
||||
return uint(rootIdx)
|
||||
}
|
||||
|
||||
func qemuStageOptions(filename, format, compat string) *osbuild.QEMUStageOptions {
|
||||
var options osbuild.QEMUFormatOptions
|
||||
switch format {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue