## v20
+- We don't automatically set `--offline=no` anymore when we detect the
+ `Subvolumes=` setting is used in a `systemd-repart` partition
+ definition file. Instead, use the new `RepartOffline` option to
+ explicitly disable running `systemd-repart` in offline mode.
- During the image build we now install UKIs/kernels/initrds to `/boot`
instead of `/efi`. While this will generally not be noticeable, users
with custom systemd-repart ESP partition definitions will need to add
format_tree,
parse_config,
summary,
+ yes_no,
)
from mkosi.distributions import Distribution
from mkosi.installer import clean_package_manager_metadata, package_manager_scripts
"--dry-run=no",
"--json=pretty",
"--no-pager",
- "--offline=yes",
+ f"--offline={yes_no(state.config.repart_offline)}",
"--seed", str(state.config.seed) if state.config.seed else "random",
state.staging / state.config.output_with_format,
]
if state.config.sector_size:
cmdline += ["--sector-size", str(state.config.sector_size)]
- if definitions:
- for d in definitions:
- cmdline += ["--definitions", d]
-
- # Subvolumes= only works with --offline=no.
- grep = run(["grep", "--recursive", "--include=*.conf", "Subvolumes=", *definitions],
- stdout=subprocess.DEVNULL, check=False)
- if grep.returncode == 0:
- cmdline += ["--offline=no"]
+ for d in definitions:
+ cmdline += ["--definitions", d]
env = {
option: value
die(f"mkosi {config.minimum_version} or newer is required to build this configuration (found {__version__})")
+ for config in images:
+ if not config.repart_offline and os.getuid() != 0:
+ die(f"Must be root to build {config.name()} image configured with RepartOffline=no")
+
for config in images:
check_workspace_directory(config)
split_artifacts: bool
repart_dirs: list[Path]
sector_size: Optional[int]
+ repart_offline: bool
overlay: bool
use_subvolumes: ConfigFeature
seed: Optional[uuid.UUID]
parse=config_parse_sector_size,
help="Set the disk image sector size",
),
+ MkosiConfigSetting(
+ dest="repart_offline",
+ section="Output",
+ parse=config_parse_boolean,
+ help="Build disk images without using loopback devices",
+ default=True,
+ ),
MkosiConfigSetting(
dest="overlay",
metavar="BOOL",
Split Artifacts: {yes_no(config.split_artifacts)}
Repart Directories: {line_join_list(config.repart_dirs)}
Sector Size: {none_to_default(config.sector_size)}
+ Repart Offline: {yes_no(config.repart_offline)}
Overlay: {yes_no(config.overlay)}
Use Subvolumes: {yes_no_auto(config.use_subvolumes)}
Seed: {none_to_random(config.seed)}
: Override the default sector size that systemd-repart uses when building a disk
image.
+`Offline=`, `--offline=`
+
+: Specifies whether to build disk images using loopback devices. Enabled
+ by default. When enabled, `systemd-repart` will not use loopback
+ devices to build disk images. When disabled, `systemd-repart` will
+ always use loopback devices to build disk images.
+
+: Note that when using `Offline=no` mkosi cannot run unprivileged and
+ the image build has to be done as the root user outside of any
+ containers and with loopback devices available on the host system.
+
+: There are currently two known scenarios where `Offline=no` has to be
+ used. The first is when using `Subvolumes=` in a repart partition
+ definition file, as subvolumes cannot be created without using
+ loopback devices. The second is when creating a system with SELinux
+ and an XFS root partition. Because `mkfs.xfs` does not support
+ populating an XFS filesystem with extended attributes, loopback
+ devices have to be used to ensure the SELinux extended attributes end
+ up in the generated XFS filesystem.
+
`Overlay=`, `--overlay`
: When used together with `BaseTrees=`, the output will consist only out of
"all"
],
"RepartDirectories": [],
+ "RepartOffline": true,
"Repositories": [],
"RepositoryKeyCheck": false,
"RootPassword": [
remove_files = [],
remove_packages = ["all"],
repart_dirs = [],
+ repart_offline = True,
repositories = [],
repository_key_check = False,
root_password = ("test1234", False),