kiwi.bootloader.config Package

Submodules

kiwi.bootloader.config.base Module

class kiwi.bootloader.config.base.BootLoaderConfigBase(xml_state, root_dir, boot_dir=None, custom_args={})[source]

Bases: ABC

Base class for bootloader configuration

Parameters:
  • xml_state (object) – instance of XMLState

  • root_dir (string) – root directory path name

  • custom_args (dict) – custom bootloader arguments dictionary

create_efi_path(in_sub_dir='boot/efi')[source]

Create standard EFI boot directory structure

Parameters:

in_sub_dir (string) – toplevel directory

Returns:

Full qualified EFI boot path

Return type:

str

failsafe_boot_entry_requested()[source]

Check if a failsafe boot entry is requested

Returns:

True or False

Return type:

bool

get_boot_cmdline(boot_device, write_device=None)[source]

Boot commandline arguments passed to the kernel

Parameters:
  • boot_device (string) – boot device node. If no extra boot device exists then boot device equals root device. In case of an overlay setup the boot device equals the readonly root device

  • write_device (string) – optional overlay write device node

Returns:

kernel boot arguments

Return type:

str

get_boot_path(target='disk')[source]

Bootloader lookup path on boot device

If the bootloader reads the data it needs to boot, it does that from the configured boot device. Depending if that device is an extra boot partition or the root partition or or based on a non standard filesystem like a btrfs snapshot, the path name varies

Parameters:

target (string) – target name: disk|iso

Returns:

path name

Return type:

str

get_boot_theme()[source]

Bootloader Theme name

Returns:

theme name

Return type:

str

get_boot_timeout_seconds()[source]

Bootloader timeout in seconds

If no timeout is specified the default timeout applies

Returns:

timeout seconds

Return type:

int

get_continue_on_timeout()[source]

Check if the boot should continue after boot timeout or not

Returns:

True or False

Return type:

bool

get_gfxmode(target)[source]

Graphics mode according to bootloader target

Bootloaders which support a graphics mode can be configured to run graphics in a specific resolution and colors. There is no standard for this setup which causes kiwi to create a mapping from the kernel vesa mode number to the corresponding bootloader graphics mode setup

Parameters:

target (string) – bootloader name

Returns:

boot graphics mode

Return type:

str

get_install_image_boot_default(loader=None)[source]

Provide the default boot menu entry identifier for install images

The install image can be configured to provide more than one boot menu entry. Menu entries configured are:

  • [0] Boot From Hard Disk

  • [1] Install

  • [2] Failsafe Install

The installboot attribute controlls which of these are used by default. If not specified the boot from hard disk entry will be the default. Depending on the specified loader type either an entry number or name will be returned.

Parameters:

loader (string) – bootloader name

Returns:

menu name or id

Return type:

str

get_menu_entry_install_title()[source]

Prefixed menu entry title for install images

If no displayname is specified in the image description, the menu title is constructed from the image name

Returns:

title text

Return type:

str

get_menu_entry_title(plain=False)[source]

Prefixed menu entry title

If no displayname is specified in the image description, the menu title is constructed from the image name and build type

Parameters:

plain (bool) – indicate to add built type into title text

Returns:

title text

Return type:

str

post_init(custom_args)[source]

Post initialization method

Store custom arguments by default

Parameters:

custom_args (dict) – custom bootloader arguments

quote_title(name)[source]

Quote special characters in the title name

Not all characters can be displayed correctly in the bootloader environment. Therefore a quoting is required

Parameters:

name (string) – title name

Returns:

quoted text

Return type:

str

abstract setup_disk_boot_images(boot_uuid, lookup_path=None)[source]

Create bootloader images for disk boot

Some bootloaders requires to build a boot image the bootloader can load from a specific offset address or from a standardized path on a filesystem.

Parameters:
  • boot_uuid (string) – boot device UUID

  • lookup_path (string) – custom module lookup path

Implementation in specialized bootloader class required

abstract setup_disk_image_config(boot_uuid=None, root_uuid=None, hypervisor=None, kernel=None, initrd=None, boot_options={})[source]

Create boot config file to boot from disk.

Parameters:
  • boot_uuid (string) – boot device UUID

  • root_uuid (string) – root device UUID

  • hypervisor (string) – hypervisor name

  • kernel (string) – kernel name

  • initrd (string) – initrd name

  • boot_options (dict) – custom options dictionary required to setup the bootloader. The scope of the options covers all information needed to setup and configure the bootloader and gets effective in the individual implementation. boot_options should not be mixed up with commandline options used at boot time. This information is provided from the get_*_cmdline methods. The contents of the dictionary can vary between bootloaders or even not be needed

Implementation in specialized bootloader class required

abstract setup_install_boot_images(mbrid, lookup_path=None)[source]

Create bootloader images for ISO boot an install media

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • lookup_path (string) – custom module lookup path

Implementation in specialized bootloader class required

abstract setup_install_image_config(mbrid, hypervisor, kernel, initrd)[source]

Create boot config file to boot from install media in EFI mode.

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • hypervisor (string) – hypervisor name

  • kernel (string) – kernel name

  • initrd (string) – initrd name

Implementation in specialized bootloader class required

abstract setup_live_boot_images(mbrid, lookup_path=None)[source]

Create bootloader images for ISO boot a live ISO image

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • lookup_path (string) – custom module lookup path

Implementation in specialized bootloader class required

abstract setup_live_image_config(mbrid, hypervisor, kernel, initrd)[source]

Create boot config file to boot live ISO image in EFI mode.

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • hypervisor (string) – hypervisor name

  • kernel (string) – kernel name

  • initrd (string) – initrd name

Implementation in specialized bootloader class required

abstract setup_sysconfig_bootloader()[source]

Create or update etc/sysconfig/bootloader by parameters required according to the bootloader setup

Implementation in specialized bootloader class required

abstract write()[source]

Write config data to config file.

Implementation in specialized bootloader class required

write_meta_data(root_device=None, write_device=None, boot_options='')[source]

Write bootloader setup meta data files

Parameters:
  • root_device (string) – root device node

  • write_device (string) – overlay root write device node

  • boot_options (string) – kernel options as string

Implementation in specialized bootloader class optional

kiwi.bootloader.config.grub2 Module

class kiwi.bootloader.config.grub2.BootLoaderConfigGrub2(xml_state, root_dir, boot_dir=None, custom_args={})[source]

Bases: BootLoaderConfigBase

grub2 bootloader configuration.

post_init(custom_args)[source]

grub2 post initialization method

Parameters:

custom_args (dict) –

Contains grub config arguments

{'grub_directory_name': 'grub|grub2'}

setup_disk_boot_images(boot_uuid, lookup_path=None)[source]

Create/Provide grub2 boot images and metadata

In order to boot from the disk grub2 modules, images and theme data needs to be created and provided at the correct place in the filesystem

Parameters:
  • boot_uuid (string) – boot device UUID

  • lookup_path (string) – custom module lookup path

setup_disk_image_config(boot_uuid=None, root_uuid=None, hypervisor=None, kernel=None, initrd=None, boot_options={})[source]

Create grub2 config file to boot from disk using grub2-mkconfig

Parameters:
  • boot_uuid (string) – unused

  • root_uuid (string) – unused

  • hypervisor (string) – unused

  • kernel (string) – unused

  • initrd (string) – unused

  • boot_options (dict)

options dictionary that has to contain the root and boot device and optional volume configuration. KIWI has to mount the system prior to run grub2-mkconfig.

{
    'root_device': string,
    'boot_device': string,
    'efi_device': string,
    'system_volumes':
        volume_manager_instance.get_volumes(),
    'system_root_volume':
        volume_manager_instance.get_root_volume_name()
}
setup_install_boot_images(mbrid: SystemIdentifier, lookup_path: str | None = None) None[source]

Create/Provide grub2 boot images and metadata

In order to boot from the ISO grub2 modules, images and theme data needs to be created and provided at the correct place on the iso filesystem

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • lookup_path (string) – custom module lookup path

setup_install_image_config(mbrid, hypervisor='xen.gz', kernel='linux', initrd='initrd')[source]

Create grub2 config file to boot from an ISO install image

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • hypervisor (string) – hypervisor name

  • kernel (string) – kernel name

  • initrd (string) – initrd name

setup_live_boot_images(mbrid: SystemIdentifier, lookup_path=None)[source]

Create/Provide grub2 boot images and metadata

Calls setup_install_boot_images because no different action required

setup_live_image_config(mbrid: SystemIdentifier, hypervisor='xen.gz', kernel='linux', initrd='initrd')[source]

Create grub2 config file to boot a live media ISO image

Parameters:
  • mbrid (string) – mbrid file name on boot device

  • hypervisor (string) – hypervisor name

  • kernel (string) – kernel name

  • initrd (string) – initrd name

setup_sysconfig_bootloader()[source]

Create or update etc/sysconfig/bootloader by parameters required according to the bootloader setup

Implementation in specialized bootloader class required

write()[source]

Write bootloader configuration

  • writes grub.cfg template by KIWI if template system is used

  • creates an embedded fat efi image for EFI ISO boot

write_meta_data(root_device=None, write_device=None, boot_options='')[source]

Write bootloader setup meta data files

  • cmdline arguments initialization

  • etc/default/grub setup file

  • etc/default/zipl2grub.conf.in (s390 only)

  • etc/sysconfig/bootloader

Parameters:
  • root_device (string) – root device node

  • write_device (string) – overlay root write device node

  • boot_options (string) – kernel options as string

  • iso_boot (bool) – indicate target is an ISO

kiwi.bootloader.config.systemd_boot Module

class kiwi.bootloader.config.systemd_boot.BootLoaderSystemdBoot(xml_state, root_dir, boot_dir=None, custom_args={})[source]

Bases: BootLoaderSpecBase

create_loader_image(target: str) None[source]

Handle EFI images

For systemd boot EFI images are provided along with systemd. Thus the only action taken care of is the creation of the ESP path

Parameters:

target (str) – target identifier, one of disk, live(iso) or install(iso)

set_loader_entry(root_dir: str, target: str) None[source]

Setup/update loader entries

Parameters:

target (str) – target identifier, one of disk, live(iso) or install(iso)

setup_loader(target: str) None[source]

Setup ESP for systemd-boot using bootctl

For disk images only, setup the ESP layout for systemd boot using bootctl. All data will be loaded from the ESP.

Parameters:

target (str) – target identifier, one of disk, live(iso) or install(iso) Currently only the disk identifier is supported

kiwi.bootloader.config.zipl Module

class kiwi.bootloader.config.zipl.BootLoaderZipl(xml_state, root_dir, boot_dir=None, custom_args={})[source]

Bases: BootLoaderSpecBase

create_loader_image(target: str) None[source]

Nothing to be done here for zipl

Parameters:

target (str) – unused

set_loader_entry(root_dir: str, target: str) None[source]

Setup/update loader entries of the form {boot_path}/loader/entries/{get_entry_name}

Parameters:

target (str) – target identifier, one of disk, live(iso) or install(iso)

setup_loader(target: str) None[source]

Setup temporary zipl config and install zipl for supported targets. Please note we are not touching the main zipl.conf file provided by the distributors

Parameters:

target (str) – target identifier, one of disk, live(iso) or install(iso) Currently only the disk identifier is supported

Module Contents

kiwi.bootloader.config.create_boot_loader_config(*, name: Literal['grub2'], xml_state: object, root_dir: str, boot_dir: str = None, custom_args: Dict = None) BootLoaderConfigGrub2[source]
kiwi.bootloader.config.create_boot_loader_config(*, name: Literal['grub2_s390x_emu'], xml_state: object, root_dir: str, boot_dir: str = None, custom_args: Dict = None) BootLoaderConfigGrub2
kiwi.bootloader.config.create_boot_loader_config(*, name: Literal['systemd_boot'], xml_state: object, root_dir: str, boot_dir: str = None, custom_args: Dict = None) BootLoaderSystemdBoot
kiwi.bootloader.config.create_boot_loader_config(*, name: Literal['zipl'], xml_state: object, root_dir: str, boot_dir: str = None, custom_args: Dict = None) BootLoaderZipl
kiwi.bootloader.config.create_boot_loader_config(*, name: str, xml_state: object, root_dir: str, boot_dir: str = None, custom_args: Dict = None) BootLoaderConfigGrub2 | BootLoaderSystemdBoot | BootLoaderZipl