support user-defined partition numbers for GPT disks

Partitions by default are indexed starting at 1, but in
some cases, such as CoreOS for IBM Z, it may be usefull
to set the 'partnum' for GPT disks explicitly, without
creating dummy partitions.

Now user can define an image:

```
    mpp-define-images:
      - id: image
        size: 10737418240
        table:
          uuid: 00000000-0000-4000-a000-000000000001
          label: gpt
          partitions:
            - name: boot
              type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
	      partnum: 3
              size: 786432
            - name: root
              type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
	      partnum: 4
              size: 4194304
```

So target disk would look like:

```
    Disklabel type: gpt
    Disk identifier: 00000000-0000-4000-A000-000000000001
    Device        Start     End Sectors  Size Type
    /dev/loop0p3   2048  788479  786432  384M Linux filesystem
    /dev/loop0p4 788480 4982783 4194304    2G Linux filesystem
```

This patch updates the osbuild-mpp tool and the sgdisk and sfdisk
stages to support this.

Co-authored-by: Dusty Mabe <dusty@dustymabe.com>
This commit is contained in:
Nikita Dubrovskii 2024-01-26 14:18:21 +01:00 committed by Achilleas Koutsou
parent 6b8c1872f6
commit fc185dae8c
7 changed files with 57 additions and 9 deletions

View file

@ -560,6 +560,7 @@
"partitions": [
{
"start": 2048,
"partnum": 1,
"size": 2048,
"type": "21686148-6449-6E6F-744E-656564454649",
"bootable": true,
@ -567,18 +568,21 @@
},
{
"start": 4096,
"partnum": 2,
"size": 260096,
"type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
"name": "EFI-SYSTEM"
},
{
"start": 264192,
"partnum": 3,
"size": 786432,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"name": "boot"
},
{
"start": 1050624,
"partnum": 4,
"size": 4194304,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"name": "root"
@ -806,6 +810,7 @@
"partitions": [
{
"start": 256,
"partnum": 1,
"size": 256,
"type": "21686148-6449-6E6F-744E-656564454649",
"bootable": true,
@ -813,18 +818,21 @@
},
{
"start": 512,
"partnum": 2,
"size": 32512,
"type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
"name": "EFI-SYSTEM"
},
{
"start": 33024,
"partnum": 3,
"size": 98304,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"name": "boot"
},
{
"start": 131328,
"partnum": 4,
"size": 524288,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"name": "root"

View file

@ -31,18 +31,22 @@ mpp-define-images:
bootable: true
size:
mpp-format-int: "{bios_boot_size_mb * 1024 * 1024 / sector_size}"
partnum: 1
- name: EFI-SYSTEM
type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
size:
mpp-format-int: "{efi_system_size_mb * 1024 * 1024 / sector_size}"
partnum: 2
- name: boot
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
size:
mpp-format-int: "{boot_size_mb * 1024 * 1024 / sector_size}"
partnum: 3
- name: root
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
size:
mpp-format-int: "{root_size_mb * 1024 * 1024 / sector_size}"
partnum: 4
- id: image4k
sector_size:
mpp-format-int: "{four_k_sector_size}"

View file

@ -1231,6 +1231,7 @@
"partitions": [
{
"start": 2048,
"partnum": 1,
"size": 2048,
"type": "21686148-6449-6E6F-744E-656564454649",
"bootable": true,
@ -1238,18 +1239,21 @@
},
{
"start": 4096,
"partnum": 2,
"size": 204800,
"type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
"uuid": "68B2905B-DF3E-4FB3-80FA-49D1E773AA33"
},
{
"start": 208896,
"partnum": 3,
"size": 204800,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"uuid": "61B2905B-DF3E-4FB3-80FA-49D1E773AA32"
},
{
"start": 413696,
"partnum": 4,
"size": 20555776,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"uuid": "CA7D7CCB-63ED-4C53-861C-1742536059CC"

View file

@ -11,17 +11,21 @@ mpp-define-image:
type: 21686148-6449-6E6F-744E-656564454649
bootable: true
uuid: FAC7F1FB-3E8D-4137-A512-961DE09A5549
partnum: 1
- id: efi
size: 204800
type: C12A7328-F81F-11D2-BA4B-00A0C93EC93B
uuid: 68B2905B-DF3E-4FB3-80FA-49D1E773AA33
partnum: 2
- id: boot
size: 204800
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
uuid: 61B2905B-DF3E-4FB3-80FA-49D1E773AA32
partnum: 3
- id: luks
type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
uuid: CA7D7CCB-63ED-4C53-861C-1742536059CC
partnum: 4
pipelines:
- mpp-import-pipelines:
path: fedora-vars.ipp.yaml