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)[source]

Size of device in bytes

Parameters:device (string) – node name
get_device()[source]

Representation of device nodes

Could provide one ore more devices representing the storage Implementation in specialized device provider class

get_uuid(device)[source]

UUID of device

Parameters:device (string) – node name
is_loop()[source]

Check if device provider is loop based

By default this is always False and needs an implementation in the the specialized device provider class

kiwi.storage.disk Module

class kiwi.storage.disk.Disk(table_type, storage_provider)[source]

Bases: kiwi.storage.device_provider.DeviceProvider

Implements storage disk and partition table setup

Attributes

  • storage_provider
    Instance of class based on DeviceProvider
  • partition_map
    Dict of internal partition names to device node name
  • public_partition_id_map
    Dict of public partition names to partition number
  • partition_id_map
    Dict of internal partition names to partition number
  • is_mapped
    Indicate if partitions are kpartx mapped
  • partitioner
    Instance of Partitioner
  • table_type
    Partition table type
activate_boot_partition()[source]

Activate boot partition

Note: not all Partitioner instances supports this

create_boot_partition(mbsize)[source]

Create boot partition

Populates kiwi_BootPart(id)

Parameters:mbsize (int) – partition size
create_efi_csm_partition(mbsize)[source]

Create EFI bios grub partition

Populates kiwi_BiosGrub(id)

Parameters:mbsize (int) – partition size
create_efi_partition(mbsize)[source]

Create EFI partition

Populates kiwi_EfiPart(id)

Parameters:mbsize (int) – partition size
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)[source]

Create prep partition

Populates kiwi_PrepPart(id)

Parameters:mbsize (int) – partition size
create_root_lvm_partition(mbsize)[source]

Create root partition for use with LVM

Populates kiwi_RootPart(id) and kiwi_RootPartVol(LVRoot)

Parameters:mbsize (int) – partition size
create_root_partition(mbsize)[source]

Create root partition

Populates kiwi_RootPart(id) and kiwi_BootPart(id) if no extra boot partition is requested

Parameters:mbsize (int) – partition size
create_root_raid_partition(mbsize)[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/md0)

Parameters:mbsize (int) – partition size
create_root_readonly_partition(mbsize)[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 (int) – partition size
create_spare_partition(mbsize)[source]

Create spare partition for custom use

Populates kiwi_SparePart(id)

Parameters:mbsize (int) – partition size
get_device()[source]

Names of partition devices

Note that the mapping requires an explicit map() call

Returns:instances of MappedDevice
Return type:dict
get_public_partition_id_map()[source]

Populated partition name to number map

is_loop()[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

map_partitions()[source]

Map/Activate partitions

In order to access the partitions through a device node it is required to map them if the storage provider is loop based

wipe()[source]

Zap (destroy) any GPT and MBR data structures if present For DASD disks create a new VTOC table

kiwi.storage.loop_device Module

class kiwi.storage.loop_device.LoopDevice(filename, filesize_mbytes=None, blocksize_bytes=None)[source]

Bases: kiwi.storage.device_provider.DeviceProvider

Create and manage loop device file for block operations

Attributes

  • node_name
    loop device node name
  • filename
    loop file name to create
  • filesize_mbytes
    size of the loop file
  • blocksize_bytes
    blocksize used in loop driver
create()[source]

Setup a loop device of the specified size and blocksize

get_device()[source]

Device node name

Returns:device node name
Return type:string
is_loop()[source]

Always True

Return type:bool

kiwi.storage.luks_device Module

class kiwi.storage.luks_device.LuksDevice(storage_provider)[source]

Bases: kiwi.storage.device_provider.DeviceProvider

Implements luks setup on a storage device

Attributes

  • storage_provider
    Instance of class based on DeviceProvider
  • luks_device
    LUKS device node name
  • luks_name
    LUKS map name, set to: luksRoot
  • option_map
    dict of distribution specific luks options
create_crypto_luks(passphrase, os=None, options=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

create_crypttab(filename)[source]

Create crypttab, setting the UUID of the storage device

get_device()[source]

Instance of MappedDevice providing the luks device

Returns:mapped luks device
Return type:MappedDevice
is_loop()[source]

Check if storage provider is loop based

Return loop status from base storage provider

Return type:bool

kiwi.storage.mapped_device Module

class kiwi.storage.mapped_device.MappedDevice(device, device_provider)[source]

Bases: kiwi.storage.device_provider.DeviceProvider

Hold a reference on a single device

Attributes

  • device_provider
    Instance of class based on DeviceProvider
  • device
    Device node name
get_device()[source]

Mapped device node name

Returns:device node name
Return type:string
is_loop()[source]

Check if storage provider is loop based

Return loop status from base storage provider

Return type:bool

kiwi.storage.raid_device Module

class kiwi.storage.raid_device.RaidDevice(storage_provider)[source]

Bases: kiwi.storage.device_provider.DeviceProvider

Implement raid setup on a storage device

Attributes

  • storage_provider
    Instance of class based on DeviceProvider
  • raid_level_map
    dict mapping raid level name to number
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)[source]

Create mdadm config file from mdadm request

Parameters:filename (string) – config file name
get_device()[source]

Instance of MappedDevice providing the raid device

Returns:mapped raid device
Return type:MappedDevice
is_loop()[source]

Check if storage provider is loop based

Return loop status from base storage provider

Return type:bool

kiwi.storage.setup Module

class kiwi.storage.setup.DiskSetup(xml_state, root_dir)[source]

Bases: object

Implement disk setup methods providing information required before building a disk image

Attributes

  • configured_size
    Configured size setup
  • build_type_name
    Configured build type name
  • filesystem
    Configured filesystem name
  • bootpart_requested
    Configured request for a boot partition
  • bootpart_mbytes
    Configured boot partition size
  • mdraid
    Configured raid setup
  • luks
    Configured LUKS credentials
  • volume_manager
    Configured volume manager name
  • bootloader
    Configured bootloader
  • oemconfig
    Configured oemconfig section
  • volumes
    Configured volumes
  • firmware
    Instance of FirmWare
  • rootsize
    Instance of SystemSize
  • root_dir
    root directory path name
  • xml_state
    Instance of XMLState
boot_partition_size()[source]

Size of the boot partition in mbytes

Returns:boot size mbytes
Return type:int
get_boot_label()[source]

Filesystem Label to use for the boot partition

Returns:label name
Return type:string
get_disksize_mbytes()[source]

Precalculate disk size requirements in mbytes

Returns:disk size mbytes
Return type:int
get_efi_label()[source]

Filesystem Label to use for the EFI partition

Returns:label name
Return type:string
get_root_label()[source]

Filesystem Label to use for the root partition

If not specified in the XML configuration the default root label is set to ‘ROOT’

Returns:label name
Return type:string
need_boot_partition()[source]

Decide if an extra boot partition is needed. This is done with the bootpartition attribute from the type, however if it is not set it depends on some other type configuration parameters if we need a boot partition or not

Return type:bool

Module Contents