devices: add new vg_partnum parameter

This is needed for bootc where all mounts need to be from the same
physical disk/loop so that bootupd works. The idea is that in the
manifest the new option `vg_partnum` is added and the parent VG
is found via the partition number of the full image similar to
the `partnum` from https://github.com/osbuild/osbuild/pull/1501

A manifest using this feature looks like this:
```json
"devices": {
  "disk": {
    "type": "org.osbuild.loopback",
    "options": {
      "filename": "disk.raw",
      "partscan": true
    }
  },
  "rootlv": {
    "type": "org.osbuild.lvm2.lv",
    "parent": "disk",
    "options": {
      "volume": "rootlv",
      "vg_partnum": 4
    }
  }
}
```

Co-authored-by: Michael Vogt <mvogt@redhat.com>
This commit is contained in:
Achilleas Koutsou 2024-08-26 09:23:27 +02:00
parent 6788a2c840
commit 0695911d5c

View file

@ -44,6 +44,10 @@ SCHEMA = """
"volume": {
"type": "string",
"description": "Logical volume to active"
},
"vg_partnum": {
"type": "number",
"description": "Partition number on the parent device where the LV's volume group is located"
}
}
"""
@ -182,6 +186,9 @@ class LVService(devices.DeviceService):
# Find the volume group that belongs to the device specified
# via `parent`
part = options.get("vg_partnum")
if part:
parent_path += f"p{part}"
vg = self.volume_group_for_device(parent_path)
# Activate the logical volume