+++ /dev/null
----
-title: Building a bootable image on different distros
-category: Tutorials
-layout: default
-SPDX-License-Identifier: LGPL-2.1-or-later
----
-
-# Building a bootable image on different distros
-
-To build a bootable image, you'll need to install a list of packages
-that differs depending on the distribution. We give an overview here of
-what's needed to generate a bootable image for some common
-distributions:
-
-## Arch
-
-```conf
-[Distribution]
-Distribution=arch
-
-[Content]
-Bootable=yes
-Packages=linux
- systemd
-```
-
-## Fedora
-
-```conf
-[Distribution]
-Distribution=fedora
-
-[Content]
-Bootable=yes
-Packages=kernel
- systemd
- systemd-boot
- udev
- util-linux
-```
-
-## CentOS
-
-```conf
-[Distribution]
-Distribution=centos
-
-[Content]
-Bootable=yes
-Packages=kernel
- systemd
- systemd-boot
- udev
-```
-
-## Debian
-
-```conf
-[Distribution]
-Distribution=debian
-
-[Content]
-Bootable=yes
-Packages=linux-image-generic
- login
- systemd
- systemd-boot
- systemd-sysv
- udev
- dbus
-```
-
-## Kali
-
-```conf
-[Distribution]
-Distribution=kali
-
-[Content]
-Bootable=yes
-Packages=linux-image-generic
- login
- systemd
- systemd-boot
- systemd-sysv
- udev
- dbus
-```
-
-## Ubuntu
-
-```conf
-[Distribution]
-Distribution=ubuntu
-Repositories=main,universe
-
-[Content]
-Bootable=yes
-Packages=linux-image-generic
- login
- systemd
- systemd-sysv
- udev
- dbus
-```
-
-## Opensuse
-
-```conf
-[Distribution]
-Distribution=opensuse
-
-[Content]
-Bootable=yes
-Packages=kernel-default
- systemd
- udev
-```
# SPDX-License-Identifier: LGPL-2.1-or-later
+[Include]
+Include=mkosi-vm
+
[Build]
CacheDirectory=mkosi.cache
History=yes
BuildSourcesEphemeral=yes
Packages=
- bash
binutils
gdb
- less
- nano
- strace
sudo
- systemd
tmux
- udev
zsh
InitrdPackages=
[Content]
Packages=
- base
- bash
- dbus-broker
- dbus-broker-units
- fish
grub
- iproute
- iputils
- linux
openssh
perf
- polkit
python
qemu-user-static
shim
- strace
# test unsigned shim.
ShimBootloader=none
Packages=
- kernel
kernel-tools
- systemd-networkd
- tpm2-tss
# CentOS Stream 10 does not ship an unsigned shim
ShimBootloader=none
Packages=
- kernel-core
linux-firmware
perf
+++ /dev/null
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Architecture=x86-64
-
-[Content]
-Packages=
- linux-image-cloud-amd64
+++ /dev/null
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Architecture=x86
-
-[Content]
-Packages=
- linux-image-686
[Content]
Packages=
fish
- kernel-core
perf
qemu-user-static
rpmautospec
- systemd-networkd
+++ /dev/null
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Architecture=x86-64
-
-[Content]
-Packages=
- linux-image-cloud-amd64
+++ /dev/null
-# SPDX-License-Identifier: LGPL-2.1-or-later
-
-[Match]
-Architecture=x86
-
-[Content]
-Packages=
- linux-image-686
# OpenSUSE does not ship an unsigned shim
ShimBootloader=none
Packages=
- bash
diffutils
fish
- iproute
- iputils
- kernel-kvmsmall
- libtss2-esys0
- libtss2-mu0
- libtss2-rc0
- libtss2-tcti-device0
openssh-clients
openssh-server
- patterns-base-minimal_base
perf
- polkit
python3
qemu-linux-user
shim
- strace
sudo-policy-wheel-auth-self
- systemd-boot
[Content]
Packages=
- linux-image-virtual
- linux-tools-virtual
+ linux-tools-generic
[Content]
Packages=
- bash
- iproute
- iputils
openssh-clients
openssh-server
- polkit
python3
rpm-build
- strace
- systemd-resolved
Packages=
grub2-efi
shim
- systemd-boot
[Content]
Packages=
- ?exact-name(systemd-boot)
- ?exact-name(systemd-resolved)
- ^libtss2-esys-[0-9.]+-0$
- ^libtss2-mu[0-9.-]+$
- bash
- dbus-broker
fish
- iproute2
- iputils-ping
- libtss2-rc0
- libtss2-tcti-device0
- login
openssh-client
openssh-server
- polkitd
python3
qemu-user-static
shim-signed
- strace
- systemd-coredump
- systemd-sysv
- tzdata
ConfigDefaultCallback = Callable[[argparse.Namespace], Any]
-BUILTIN_CONFIGS = ("mkosi-tools", "mkosi-initrd")
+BUILTIN_CONFIGS = ("mkosi-tools", "mkosi-initrd", "mkosi-vm")
class Verb(StrEnum):
Note that each path containing extra configuration is only parsed
once, even if included more than once with `Include=`.
- The builtin configs for the mkosi default initrd and default tools
- tree can be included by including the literal value `mkosi-initrd` and
- `mkosi-tools` respectively.
+ The builtin configs for the mkosi default initrd, default tools tree
+ and default virtual machine image can be included by including the
+ literal value `mkosi-initrd`, `mkosi-tools` or `mkosi-vm`
+ respectively.
Note: Include names starting with either of the literals `mkosi-` or
`contrib-` are reserved for use by mkosi itself.
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Content]
+Bootable=yes
+
+Packages=
+ bash
+ diffutils
+ gawk
+ grep
+ gzip
+ less
+ nano
+ sed
+ strace
+ systemd
+ udev
+ which
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=arch
+
+[Content]
+Packages=
+ dbus-broker
+ dbus-broker-units
+ iproute
+ iputils
+ linux
+ polkit
+ tpm2-tss
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=|alma
+Distribution=|rocky
+Distribution=|centos
+Distribution=|fedora
+Distribution=|azure
+
+[Content]
+Packages=
+ iproute
+ iputils
+ kernel
+ polkit
+ systemd-resolved
+ tpm2-tss
+ util-linux
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
-Architecture=arm64
+Distribution=|fedora
+Distribution=|azure
[Content]
Packages=
- linux-image-cloud-arm64
+ systemd-networkd
# SPDX-License-Identifier: LGPL-2.1-or-later
[Match]
-Architecture=arm64
+Architecture=|x86-64
+Architecture=|arm64
[Content]
Packages=
- linux-image-cloud-arm64
+ systemd-boot
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=|debian
+Distribution=|kali
+Distribution=|ubuntu
+
+[Content]
+Packages=
+ ?exact-name(systemd-boot)
+ ?exact-name(systemd-resolved)
+ bash
+ dbus-broker
+ iproute2
+ iputils-ping
+ linux-image-generic
+ login
+ polkitd
+ systemd-boot
+ systemd-coredump
+ systemd-sysv
+ tpm2-tools
+ tzdata
--- /dev/null
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=opensuse
+
+[Content]
+Packages=
+ iproute
+ iputils
+ kernel-default
+ libtss2-tcti-device0
+ patterns-base-minimal_base
+ polkit
+ strace
+ systemd-boot
+ systemd-network
+ tpm2.0-tools
"man/*",
"mkosi-initrd/**/*",
"mkosi-tools/**/*",
+ "mkosi-vm/**/*",
"repart/**/*",
]
import pytest
+import mkosi.resources
from mkosi.config import parse_config
from mkosi.distributions import Distribution, detect_distribution
+from mkosi.util import resource_path
from . import ImageConfig, ci_group
@pytest.fixture(scope="session")
def config(request: Any) -> ImageConfig:
distribution = cast(Distribution, request.config.getoption("--distribution"))
- release = cast(
- str, request.config.getoption("--release") or parse_config(["-d", str(distribution)])[1][0].release
- )
+ with resource_path(mkosi.resources) as resources:
+ release = cast(
+ str,
+ request.config.getoption("--release")
+ or parse_config(["-d", str(distribution)], resources=resources)[1][0].release,
+ )
return ImageConfig(
distribution=distribution,
release=release,
# The fallback value is for CentOS and related distributions.
maxsize = 1024**2 * {
- Distribution.fedora: 55,
- Distribution.debian: 55,
- Distribution.ubuntu: 50,
+ Distribution.fedora: 56,
+ Distribution.debian: 58,
+ Distribution.ubuntu: 54,
Distribution.arch: 80,
- Distribution.opensuse: 55,
+ Distribution.opensuse: 62,
}.get(config.distribution, 55)
assert (Path(image.output_dir) / "image.initrd").stat().st_size <= maxsize