This allows us to map in a whole disk as a loopback device with parition
scanning rather than slicing up the disk and creating several loopback
devices. Something like this:
```
- type: org.osbuild.copy
inputs:
tree:
type: org.osbuild.tree
origin: org.osbuild.pipeline
references:
- name:tree
options:
paths:
- from: input://tree/
to: mount://root/
devices:
efi:
type: org.osbuild.loopback
options:
filename: disk.img
start:
mpp-format-int: '{image.layout[''EFI-SYSTEM''].start}'
size:
mpp-format-int: '{image.layout[''EFI-SYSTEM''].size}'
boot:
type: org.osbuild.loopback
options:
filename: disk.img
start:
mpp-format-int: '{image.layout[''boot''].start}'
size:
mpp-format-int: '{image.layout[''boot''].size}'
root:
type: org.osbuild.loopback
options:
filename: disk.img
start:
mpp-format-int: '{image.layout[''root''].start}'
size:
mpp-format-int: '{image.layout[''root''].size}'
mounts:
- name: root
type: org.osbuild.xfs
source: root
target: /
- name: boot
type: org.osbuild.ext4
source: boot
target: /boot
- name: efi
type: org.osbuild.fat
source: efi
target: /boot/efi
```
now becomes a little more simple:
```
- type: org.osbuild.copy
inputs:
tree:
type: org.osbuild.tree
origin: org.osbuild.pipeline
references:
- name:tree
options:
paths:
- from: input://tree/
to: mount://root/
devices:
disk:
type: org.osbuild.loopback
options:
filename: disk.img
partscan: true
mounts:
- name: root
type: org.osbuild.xfs
source: disk
partition:
mpp-format-int: '{image.layout[''root''].partnum}'
target: /
- name: boot
type: org.osbuild.ext4
source: disk
partition:
mpp-format-int: '{image.layout[''boot''].partnum}'
target: /boot
- name: efi
type: org.osbuild.fat
source: disk
partition:
mpp-format-int: '{image.layout[''EFI-SYSTEM''].partnum}'
target: /boot/efi
```
Fixes https://github.com/osbuild/osbuild/issues/1495
76 lines
1.6 KiB
Python
Executable file
76 lines
1.6 KiB
Python
Executable file
#!/usr/bin/python3
|
|
"""
|
|
FAT mount service
|
|
|
|
Mount a FAT filesystem at the given location.
|
|
|
|
Host commands used: mount
|
|
"""
|
|
|
|
import sys
|
|
from typing import Dict
|
|
|
|
from osbuild import mounts
|
|
|
|
SCHEMA_2 = """
|
|
"additionalProperties": false,
|
|
"required": ["name", "type", "source", "target"],
|
|
"properties": {
|
|
"name": { "type": "string" },
|
|
"type": { "type": "string" },
|
|
"source": {
|
|
"type": "string"
|
|
},
|
|
"target": {
|
|
"type": "string"
|
|
},
|
|
"partition": {
|
|
"description": "If the source device has partitions, the partition number, starting at one",
|
|
"type": "number"
|
|
},
|
|
"options": {
|
|
"type": "object",
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"readonly": {
|
|
"description": "mount the source as a readonly device",
|
|
"type": "boolean",
|
|
"default": false
|
|
},
|
|
"uid": {
|
|
"description": "mount the source with given uid",
|
|
"type": "integer"
|
|
},
|
|
"gid": {
|
|
"description": "mount the source with given guid",
|
|
"type": "integer"
|
|
},
|
|
"umask": {
|
|
"description": "mount the source with given umask",
|
|
"type": "string",
|
|
"pattern": "^[0-7][0-7][0-7]$"
|
|
},
|
|
"shortname": {
|
|
"description": "mount the source with given shortname",
|
|
"type": "string",
|
|
"enum": ["lower", "win95", "winnt", "mixed"]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
"""
|
|
|
|
|
|
class FatMount(mounts.FileSystemMountService):
|
|
|
|
def translate_options(self, options: Dict):
|
|
return ["-t", "vfat"] + super().translate_options(options)
|
|
|
|
|
|
def main():
|
|
service = FatMount.from_args(sys.argv[1:])
|
|
service.main()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|