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
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

get_uuid(device)[source]

UUID of device

Parameters:device (string) – node name
Returns:UUID from blkid
Return type:str
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

Returns:True or False
Return type:bool

kiwi.storage.disk Module

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

Bases: kiwi.storage.device_provider.DeviceProvider

Implements storage disk and partition table setup

Parameters:
  • table_type (string) – Partition table type name
  • storage_provider (object) – Instance of class based on DeviceProvider
  • start_sector (int) – sector number
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/mdX)

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

Returns:True or False
Return type:bool
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

Parameters:
  • filename (string) – loop file name to create
  • filesize_mbytes (int) – size of the loop file
  • blocksize_bytes (int) – blocksize used in loop driver
create(overwrite=True)[source]

Setup a loop device of the blocksize given in the constructor The file to loop is created with the size specified in the constructor unless an existing one should not be overwritten

Parameters:overwrite (bool) – overwrite existing file to loop
get_device()[source]

Device node name

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

Always True

Returns: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

Parameters:storage_provider (object) – Instance of class based on DeviceProvider
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

Parameters:
  • passphrase (string) – credentials
  • os (string) – distribution name to match distribution specific options for cryptsetup
  • options (list) – further cryptsetup options
create_crypttab(filename)[source]

Create crypttab, setting the UUID of the storage device

Parameters:filename (string) – file path name
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

Returns:True or False
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

Parameters:
  • device_provider (object) – Instance of class based on DeviceProvider
  • device (string) – Device node name
get_device()[source]

Mapped device node name

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

Check if storage provider is loop based

Return loop status from base storage provider

Returns:True or False
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

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

Returns:True or False
Return type:bool

kiwi.storage.setup Module

class kiwi.storage.setup.DiskSetup(xml_state, root_dir)[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()[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:str
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:str
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:str
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

Returns:True or False
Return type:bool

Module Contents