kiwi.storage Package¶
Submodules¶
kiwi.storage.device_provider
Module¶
- class kiwi.storage.device_provider.DeviceProvider[source]¶
Bases:
object
Base class for any class providing storage devices
- get_byte_size(device: str) int [source]¶
Size of device in bytes
- Parameters:
device (string) – node name
- Returns:
byte value from blockdev
- Return type:
int
- get_device()[source]¶
Representation of device nodes
Could provide one ore more devices representing the storage Implementation in specialized device provider class
kiwi.storage.disk
Module¶
- class kiwi.storage.disk.Disk(table_type: str, storage_provider: DeviceProvider, start_sector: int | None = None, extended_layout: bool = False)[source]¶
Bases:
DeviceProvider
Implements storage disk and partition table setup
- activate_boot_partition()[source]¶
Activate boot partition
Note: not all Partitioner instances supports this
- create_boot_partition(mbsize: str, clone: int = 0)[source]¶
Create boot partition
Populates kiwi_BootPart(id) and optional kiwi_BootPartClone(id)
- Parameters:
mbsize (str) – partition size string
clone (int) – create [clone] cop(y/ies) of the boot partition
- create_custom_partitions(table_entries: Dict[str, ptable_entry_type]) None [source]¶
Create partitions from custom data set
table_entries = { map_name: ptable_entry_type }
- Parameters:
table (dict) – partition table spec
- create_efi_csm_partition(mbsize: str)[source]¶
Create EFI bios grub partition
Populates kiwi_BiosGrub(id)
- Parameters:
mbsize (str) – partition size string
- create_efi_partition(mbsize: str)[source]¶
Create EFI partition
Populates kiwi_EfiPart(id)
- Parameters:
mbsize (str) – partition size string
- create_hybrid_mbr()[source]¶
Turn partition table into a hybrid GPT/MBR table
Note: only GPT tables supports this
- create_mbr()[source]¶
Turn partition table into MBR (msdos table)
Note: only GPT tables supports this
- create_prep_partition(mbsize: str)[source]¶
Create prep partition
Populates kiwi_PrepPart(id)
- Parameters:
mbsize (str) – partition size string
- create_root_lvm_partition(mbsize: str, clone: int = 0)[source]¶
Create root partition for use with LVM
Populates kiwi_RootPart(id)
- Parameters:
mbsize (str) – partition size string
clone (int) – create [clone] cop(y/ies) of the lvm roo partition
- create_root_partition(mbsize: str, clone: int = 0)[source]¶
Create root partition
Populates kiwi_RootPart(id) and kiwi_BootPart(id) if no extra boot partition is requested
- Parameters:
mbsize (str) – partition size string
clone (int) – create [clone] cop(y/ies) of the root partition
- create_root_raid_partition(mbsize: str, clone: int = 0)[source]¶
Create root partition for use with MD Raid
Populates kiwi_RootPart(id) and kiwi_RaidPart(id) as well as the default raid device node at boot time which is configured to be kiwi_RaidDev(/dev/mdX)
- Parameters:
mbsize (str) – partition size string
clone (int) – create [clone] cop(y/ies) of the raid root partition
- create_root_readonly_partition(mbsize: str, clone: int = 0)[source]¶
Create root readonly partition for use with overlayfs
Populates kiwi_ReadOnlyPart(id), the partition is meant to contain a squashfs readonly filesystem. The partition size should be the size of the squashfs filesystem in order to avoid wasting disk space
- Parameters:
mbsize (str) – partition size string
clone (int) – create [clone] cop(y/ies) of the ro root partition
- create_spare_partition(mbsize: str)[source]¶
Create spare partition for custom use
Populates kiwi_SparePart(id)
- Parameters:
mbsize (str) – partition size string
- create_swap_partition(mbsize: str)[source]¶
Create swap partition
Populates kiwi_SwapPart(id)
- Parameters:
mbsize (str) – partition size string
- get_device() Dict[str, MappedDevice] [source]¶
Names of partition devices
Note that the mapping requires an explicit map() call
- Returns:
instances of MappedDevice
- Return type:
dict
- is_loop() bool [source]¶
Check if storage provider is loop based
The information is taken from the storage provider. If the storage provider is loop based the disk is it too
- Returns:
True or False
- Return type:
bool
- class kiwi.storage.disk.ptable_entry_type(mbsize, clone, partition_name, partition_type, mountpoint, filesystem)¶
Bases:
tuple
- clone: int¶
Alias for field number 1
- filesystem: str¶
Alias for field number 5
- mbsize: int¶
Alias for field number 0
- mountpoint: str¶
Alias for field number 4
- partition_name: str¶
Alias for field number 2
- partition_type: str¶
Alias for field number 3
kiwi.storage.loop_device
Module¶
- class kiwi.storage.loop_device.LoopDevice(filename: str, filesize_mbytes: int | None = None, blocksize_bytes: int | None = None)[source]¶
Bases:
DeviceProvider
Create and manage loop device file for block operations
- Parameters:
filename (string) – loop file name to create
filesize_mbytes (int) – size of the loop file
blocksize_bytes (int) – blocksize used in loop driver
kiwi.storage.luks_device
Module¶
- class kiwi.storage.luks_device.LuksDevice(storage_provider: DeviceProvider)[source]¶
Bases:
DeviceProvider
Implements luks setup on a storage device
- Parameters:
storage_provider (object) – Instance of class based on DeviceProvider
- create_crypto_luks(passphrase: str, osname: str | None = None, options: list | None = None, keyfile: str = '', randomize: bool = True, root_dir: str = '') None [source]¶
Create luks device. Please note the passphrase is readable at creation time of this image. Make sure your host system is secure while this process runs
- Parameters:
passphrase (string) – credentials
osname (string) – distribution name to match distribution specific options for cryptsetup
options (list) – further cryptsetup options
keyfile (string) – file path name file path name which contains an alternative key to unlock the luks device
root_dir (string) – root dir path
- create_crypttab(filename: str) None [source]¶
Create crypttab, setting the UUID of the storage device
- Parameters:
filename (string) – file path name
- static create_random_keyfile(filename: str) None [source]¶
Create keyfile with random data
- Parameters:
filename (string) – file path name
- get_device() MappedDevice | None [source]¶
Instance of MappedDevice providing the luks device
- Returns:
mapped luks device
- Return type:
kiwi.storage.mapped_device
Module¶
- class kiwi.storage.mapped_device.MappedDevice(device: str, device_provider: DeviceProvider)[source]¶
Bases:
DeviceProvider
Hold a reference on a single device
- Parameters:
device_provider (object) – Instance of class based on DeviceProvider
device (string) – Device node name
kiwi.storage.raid_device
Module¶
- class kiwi.storage.raid_device.RaidDevice(storage_provider: DeviceProvider)[source]¶
Bases:
DeviceProvider
Implement raid setup on a storage device
- Parameters:
storage_provider (object) – Instance of class based on DeviceProvider
- create_degraded_raid(raid_level)[source]¶
Create a raid array in degraded mode with one device missing. This only works in the raid levels 0(striping) and 1(mirroring)
- Parameters:
raid_level (string) – raid level name
- create_raid_config(filename: str) None [source]¶
Create mdadm config file from mdadm request
- Parameters:
filename (string) – config file name
- get_device() MappedDevice | None [source]¶
Instance of MappedDevice providing the raid device
- Returns:
mapped raid device
- Return type:
kiwi.storage.clone_device
Module¶
- class kiwi.storage.clone_device.CloneDevice(source_provider: DeviceProvider, root_dir: str)[source]¶
Bases:
DeviceProvider
Implements device cloning
- clone(target_devices: List[DeviceProvider])[source]¶
Clone source device to target device(s)
- Parameters:
target_devices (list) – List of target DeviceProvider instances
kiwi.storage.setup
Module¶
- class kiwi.storage.setup.DiskSetup(xml_state: XMLState, root_dir: str)[source]¶
Bases:
object
Implements disk setup methods
Methods from this class provides information required before building a disk image
- Parameters:
xml_state (object) – Instance of XMLState
root_dir (string) – root directory path name
- boot_partition_size() int [source]¶
Size of the boot partition in mbytes
- Returns:
boot size mbytes
- Return type:
int
- static get_boot_label() str [source]¶
Filesystem Label to use for the boot partition
- Returns:
label name
- Return type:
str
- get_disksize_mbytes(root_clone: int = 0, boot_clone: int = 0) int [source]¶
Precalculate disk size requirements in mbytes
- Parameters:
root_clone (int) – root partition gets cloned, N+1 times the size is needed
boot_clone (int) – boot partition gets cloned, N+1 times the size is needed
- Returns:
disk size mbytes
- Return type:
int
- static get_efi_label() str [source]¶
Filesystem Label to use for the EFI partition
- Returns:
label name
- Return type:
str