Commit Graph

137 Commits

Author SHA1 Message Date
Marcus Schäfer
bea1223d50
Allow initrd updates on read-only devices
Move initrd to ESP for boot loaders that reads data
from there
2025-05-08 22:07:04 +02:00
Marcus Schäfer
4238293513
Switch to dracut-kiwi-verity
So far no luck with the systemd verity generator. This
commit adds the parsing of /etc/veritytab in the existing
kiwi-verity dracut module and uses it in the overlayroot
integration test.
2025-05-08 22:07:04 +02:00
Marcus Schäfer
1753b85e12
Add support for selecting the overlay read-only fs
Add new overlayroot_readonly_filesystem attribute which allows
to select for either squashfs or erofs as the read-only filesystem
in an OEM overlay disk setup.
2025-05-08 22:07:04 +02:00
Marcus Schäfer
e9c1568904
Fix root clone size setup
If the root_clone attribute is specified without providing a
fixed size for the system, kiwi estimates the size needed for
the root part and assigns the rest to the clone. This leads to
different partition sizes for the root clones. As per definition
of a clone the expectation is that the size is the same, this
commit changes the behavior such that the calculated size for
the system is applied to the origin root and all its clones.
As a consequence this can leave unpartitioned space free in
the image. This Fixes #2463
2025-05-06 09:25:06 +02:00
Marcus Schäfer
43ea22c9fd
Fix reencryption master key passphrase
Make sure to use the correct passphrase for the master
key such that it can be decrypted with the same credentials
as before. The credentials reset is a subsequent task
after reencryption.
2025-05-02 21:28:53 +02:00
Marcus Schäfer
944998b239
Fix setup of use_disk_password for random secret
When using luks="random" in combination with use_disk_password="true"
the resulting cryptomount call in grub is wrong. This commit fixes it
2025-04-28 10:04:08 +02:00
Marcus Schäfer
d4324cebff
Fix overlayroot builds for EFI path
make sure to keep boot/efi mountpoint directories
in the read-only area as they can't be created later
2025-04-27 19:14:19 +02:00
Marcus Schäfer
67ab6b3a2d
Fix key slot selection for luks reencrypt
Depending on the type setup for a luks encrypted image, there
might be one or two key slots available. When kiwi is requested
to perform the reencryption process at least one key-slot and
the proper keyfile/passphrase must be provided. This commit
stores the information about the key-slot number for which
a decryption information exists in the initrd. In addition to
the code change also the corresponding integration test image
was updated.
2025-04-22 14:53:39 +02:00
Marcus Schäfer
0eb2d2713e
Added disk validation for duplicate installs
Installing the same image to different storage disks on the
same machine creates device conflicts with unexpected side
effects. This commit adds a validation based on the PTUUID
of the disk image to check if another device on the system
has the same ID and if yes, does not allow to install the
image again including a message which device takes the same
identifier. This references bsc#1228741
2025-01-20 18:13:02 +01:00
Marcus Schäfer
2252087593
Added LUKS reencryption support
Added rd.kiwi.oem.luks.reencrypt boot option consumed by the
kiwi-repart dracut module. For OEM LUKS2 encrypted disk images.
If set, reencrypts the disk prior an eventual resize and therefore
creates a new key pool and master key. The reencryption is advisable
if the image binary is not protected. With access to the image
binary it's possible to extract the luks header which then allows to
decrypt the data unless it was reencrypted. The reencryption process
only runs if the checksum of the luks header still matches the one
from the original disk image. Be aware that the reencryption will
ask for the passphrase if the image has been built with an initial
luks passphrase.
2025-01-10 15:12:24 +01:00
Marcus Schäfer
d4d39e481a
Drop insecure and unsupported md5 digest
Decommission the Checksum.md5() method and move all places
in code to sha256(). The md5 digest is considered insecure
and has also been removed from hashlib as a supported digest.
This Fixes #2696
2024-12-19 11:26:07 +01:00
Adam Williamson
75c9939f84 xorriso: respect efiparttable and gpt_hybrid_mbr
This should make the xorriso-based ISO build path respect the
'efiparttable' and 'gpt_hybrid_mbr' settings when building a
UEFI-compatible image, making it write a GPT disk label by default
instead of an MBR (msdos) one. If it's building an image that is not
UEFI-compatible it will always write an MBR label, regardless of
this setting.

If 'gpt_hybrid_mbr' is set, xorriso will write an Ubuntu-style
MBR/GPT hybrid partition table, where the MBR partition table
includes a partition with type 00 and the bootable flag, as well
as the partition with type ee required by the UEFI spec. This
mildly violates the UEFI spec but may make the image bootable on
native BIOS or CSM firmwares which refuse to boot from a disk with
no partition marked 'bootable' in the MBR. If 'gpt_hybrid_mbr' is
not set, xorriso will write a strictly UEFI-spec compliant label,
with just the 'protective MBR' required by the UEFI spec (no
bootable partition) and the correct GPT partition table. Note
this is somewhat different from what gpt_hybrid_mbr does for
disk images.

Also, we now pass -compliance no_emul_toc when building ISOs, as
recommended by upstream in
https://lists.gnu.org/archive/html/bug-xorriso/2024-11/msg00012.html
This tool is generally always going to be building ISOs intended
for write-once use, not multi-session use (and which are rarely,
these days, written to physical discs at all anyway).

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2024-12-13 11:13:27 -08:00
Marcus Schäfer
f6f21fec16
Fix legacy_bios_mode detection
The code in this method does not work correctly if the
firmware is set to 'bios'. In bios only mode the method
returned a false value which is incorrect as it should
return a true value in this case. Without this patch
ISO images will fail to boot because no loader gets
configured.
2024-12-02 13:33:00 +01:00
Marcus Schäfer
71608c1122
Fixed use of fscreateoptions for iso type
The information for fscreateoptions was not passed along to the
tooling if a custom filesystem attribute was specified.
This Fixes #2681
2024-11-25 16:30:53 +01:00
Marcus Schäfer
21056fa55d
Add missing erofscompression validation
In the filesystem builder I forgot to evaluate the
erofscompression attribute. This Fixes #2647
2024-09-17 15:07:49 +02:00
Marcus Schäfer
0506844986
Add new builder for enclaves
Add new EnclaveBuilder class which allows to build initrd-only
image types. The first enclave implementation covers aws-nitro
images produced via the eif_build tooling.
2024-09-07 22:23:59 +02:00
Neal Gompa
eb39120ea1 kiwi/builder/live: Clean up leftover dracut configuration file
The existence of this file breaks installers on live media that
sync the full filesystem to disk and are not aware of this configuration
before generating the target system initramfs.
2024-08-24 08:34:03 -04:00
Marcus Schäfer
e86e5423c0
Do not exclude the .profile env file by default
kiwi's initrd modules read a .profile file which gets included
into the initrd produced at build time. To allow rebuild of a
host-only initrd from the booted system this information should
be present such that it is possible to re-use kiwi initrd code.
2024-07-30 18:16:54 +02:00
Marcus Schäfer
5b3c761ca1
Allow to set custom ISO Application ID
Add new <type ... application_id="..."/> attribute to be set in
the ISO header main block. The application ID was used as identifier
in the legacy initrd code from former kiwi versions. Because of
this there is still the compat layer which sets an App ID as MBR
identifier string unless the new application_id overwrites it.
This Fixes #1810
2024-07-12 10:23:21 +02:00
Marcus Schäfer
8a6aed12ae
Add new eficsm type attribute
Allow to produce EFI/UEFI images without hybrid CSM
capabilities. This Fixes #2407
2024-07-11 21:40:19 +02:00
Marcus Schäfer
596942ae77
Fixed mountpoint to use for read-only property
Make sure get_mountpoint() is used to retrieve the correct
mountpoint for the root entry point. Using the self.mountpoint
member is not always correct
2024-04-15 18:33:40 +02:00
Marcus Schäfer
4fc0d2147d
Move DiskFormat to context manager
Change the DiskFormat Factory to be a context manager.
All code using DiskFormat was updated to the following
with statement:

    with DiskFormat(...).new as disk_format:
        disk_format.some_member()

This is related to Issue #2412
2024-02-29 16:42:49 +01:00
Marcus Schäfer
a39a19b35f
Move VolumeManager to context manager
Change the VolumeManager Factory to be a context manager.
All code using VolumeManager was updated to the following
with statement:

    with VolumeManager(...).new as volume_manager:
        volume_manager.some_member()

This is related to Issue #2412
2024-02-21 09:40:47 +01:00
Dan Čermák
48817a6441
Refactor Command class
Command.run() currently has a bit of a confusing behavior: if raise_on_error is
False and the executable is not found, then a weird CommandT is returned (return
code is -1 and stdout+stderr is None). This makes it possible to hanlde command
not found errors separately, but it makes that needlessly verbose. So instead,
let's just return None in *this* special case.

That in turn uncovered, that in most cases when we set `raise_on_error=True`, we
actually want an error if the command is not present but no error if the command
fails to execute (e.g. because it returns -1 if you run `$cmd --version`). Hence we
introduce the flag `raise_on_command_not_found`, which causes an exception to
be raised if the command is not found. This makes it independent of the
`raise_on_error` flag.

Additionally, we add a small optimization: if command starts with /, then we
assume it's a full path and we omit the call to which (and just check whether it
exists).

Co-authored-by: Marcus Schäfer <marcus.schaefer@gmail.com>
2024-02-19 16:33:24 +01:00
Alexandre Detiste
fb69627ad3
Use unittest.mock from core python everywhere
mock was an independent module that has been merged into the Python standard library.
2024-02-18 22:15:30 +01:00
Fabian Vogt
8064538ebf
Allow specifying the filesystem for live image, also direct squashfs
Allow specifying the filesystem for live image, also direct squashfs

By setting <type image="iso" filesystem="FSTYPE" .../> it's now possible
to specify the filesystem used for live images. By using "squashfs", the
rootfs container is skipped entirely.
2024-02-14 12:51:58 +01:00
Marcus Schäfer
09e4758609
Move Disk to context manager
Change the Disk class to be a context manager.
All code using Disk was updated to the following
with statement:

    with Disk(...) as disk:
        disk.some_member()

This is related to Issue #2412
2024-01-31 15:04:10 +01:00
Dan Čermák
882fb9019a
Add missing assert call to install_test 2024-01-29 14:08:13 +01:00
Dan Čermák
f906704ea5
Convert BootLoaderConfig to free function
The class serves really no purpose except for creating another
namespace. This function now allows us to have more stricter type checking.
2024-01-29 13:56:51 +01:00
Marcus Schäfer
54f92d2a9f
Drop support for syslinux/isolinux
SYSLINUX has been abandoned for several years now, and it does not
even work with modern versions of the filesystems supported in kiwi.
This commit drops it and Fixes #2433
2024-01-26 21:25:37 +01:00
Marcus Schäfer
d209a57910
Move BootLoaderConfig to context manager
Change the BootLoaderConfig class to be a context manager.
All code using BootLoaderConfig was updated to the following
with statement:

    with BootLoaderConfig.new(...) as bootloader_config:
        bootloader_config.some_member()

This is related to Issue #2412
2024-01-23 15:11:21 +01:00
Marcus Schäfer
a1783ffd83
Refactor disk builder for use with context manager
In preparation to further context manager related changes
in VolumeManager, LuksDevice, RaidDevice and more the
disk builder code which uses these classes needs to be
refactored beforehand to allow switching to context
manager based cascading of the storage device classes.
This commit does the refactoring and is related to
Issue #2412
2024-01-18 15:46:08 +01:00
Marcus Schäfer
ee40b83d86
Move FileSystem to context manager
Change the FileSystem class to be a context manager. All code using
FileSystem was updated to the following with statement:

with FileSystem.new(...) as filesystem:
    filesystem.some_member()

This is related to Issue #2412
2024-01-12 20:03:51 +01:00
Marcus Schäfer
cdbe5060ca
Move LoopDevice class to context manager
Change the LoopDevice class to be a context manager.
All code using LoopDevice was updated to the following
with statement:

with LoopDevice(...) as loop_provider:
    loop_provider.some_member()

This is related to Issue #2412
2024-01-11 19:18:01 +01:00
Marcus Schäfer
d6d57ea95b
Add support for ISO boot via systemd-boot
Create proper EFI FAT image via bootctl to be used as
alt loader in xorriso. This allows to boot the ISO
via EFI e.g kvm -bios /usr/share/qemu/ovmf-x86_64.bin -cdrom file.iso
Please note, hybrid boot is done via grub's hybrid MBR and
as systemd-boot does not provide one, hybrid boot is out
of scope yet. This Fixes #2281
2023-11-07 17:41:51 +01:00
Marcus Schäfer
8580b2006b
Fixed root entry in fstab for btrfs layout
A root (/) entry in fstab for btrfs is only required if no
default volume is configured. This commit adapts the code
path which adds an fstab entry for (/) to be effective only
if btrfs_set_default_volume is set to false.

Additionally, the documentation around btrfs_set_default_volume
was clarified to describe the behavior the switch triggers.

This Fixes #2366
2023-09-12 20:03:30 -04:00
Marcus Schäfer
1e4687f84d
Fix double grub entries in hybrid ISO images
As consequence of using the "source" grub command instead
of the "configfile" command to load the grub config we now
see double loading of the same file on ISO media. The reason
here is that kiwi ISO media is always hybrid which means it
embeds an MBR into the ISO for which the "source" command now
can read the same file through two different device paths.
This does not happen with the "configfile" grub command.
Thus this patch uses "configfile" if we produce an ISO image
and "source" for all other image types. The commit also fixes
the custom grub template used for ISO images in a way that
we only set the "serial" command if there is a serial
configuration provided along with the image description.
2023-08-09 16:07:34 +02:00
Dan Čermák
4df893124e
Add ContainerImageBase abstract base class for OCI & Appx 2023-08-01 08:19:22 +02:00
Dan Čermák
dfd9905755
Add type hints to the Compress module 2023-08-01 08:19:21 +02:00
Marcus Schäfer
fcf6b6e64e
Pass rootflags if no default volume is set
In case of btrfs and if btrfs_set_default_volume is explicitly
switched off, we create the correct rootflags= kernel cmdline
entry to tell the system about the root volume for booting
2023-07-31 12:53:33 +02:00
Marcus Schäfer
f8f1c0056e
Take subvol mount option for root into account
If the rootfs is btrfs based make sure the fstab entry for
it takes the name of the root subvolume into account
2023-07-26 09:21:09 +02:00
Marcus Schäfer
b3047fb947
Fixed writing correct keyfile path to etc/crypttab
The keyfile path was not correctly set in etc/crypttab which
caused systemd not being able to read the keyfile, consequently
asking for a passphrase. This commit fixes the writing of the
crypttab and also fixes a python name clash with the "os"
namespace.
2023-07-25 17:06:02 +02:00
Marcus Schäfer
b8092f0291
Fixed regression in bootloader config attr access
use_disk_password is not an attribute that exists in all
BootLoaderConfig instances. Thus it's a mistake to access
the attribute in the disk builder
2023-07-10 16:56:18 +02:00
Marcus Schäfer
7ac14458af Refactor the luks_device class data transport
Also add missing unit tests
2023-07-05 12:30:38 +02:00
Olaf Kirch
0a80ac63c6 Change location of LUKS keyfile to /root/.root.keyfile
In some configuration (eg on a transactional system), the root
file system is read-only, which means we will not be able to remove
the stale .root.keyfile after firstboot.

This patch changes the location of the keyfile and places it in
/root/.root.keyfile instead, because root's home directory is much
more likely to be read/write.

Also fixed the associated unit test (thanks to schaefi).

Signed-off-by: Olaf Kirch <okir@suse.com>
2023-07-05 12:30:29 +02:00
Marcus Schäfer
9c8b80869e
Allow to create plain cpio archives
Allow to create plain cpio archives to serve the idea
of the mkosi initrd concept
2023-05-04 12:43:48 +02:00
Marcus Schäfer
6247713b70
Fixed evaluation of custom start sector
In case an alternative partition table start sector is
configured, the check to effectively apply it should be
based on the partition table type not on the firmware
name
2023-03-30 17:49:43 +02:00
Marcus Schäfer
c304e557b0
Merge pull request #2253 from OSInside/fix_selection_of_write_partition
Fix evaluation of write partition and parameters for overlayroot setup
2023-03-25 01:00:51 +01:00
Marcus Schäfer
41875f57ea
Add support for creating delta containers
Add new attribute delta_root="true|false" which in combination with
derived_from="OCI-base-image" allows to create a delta root tree
only containing the differences between the OCI-base-image and the
actions taken by the kiwi prepare step. Based on the delta root tree
the subsequent image creation process starts. Such an incomplete
root tree is only useful under certain circumstances which is also
the reason why the feature is only available to the oci and docker
image types.
2023-03-16 17:06:15 +01:00
Marcus Schäfer
98ff0e2d8c
Fix permissions of live ISO system files
Make sure initrd and squashfs.img takes permissions o644
This Fixes #2246
2023-03-09 09:03:34 +01:00