kiwi.volume_manager Package

Submodules

kiwi.volume_manager.base Module

class kiwi.volume_manager.base.VolumeManagerBase(device_map: Dict[str, DeviceProvider], root_dir: str, volumes: List[volume_type], custom_args: Dict[str, Any] | None = None)[source]

Bases: DeviceProvider

Implements base class for volume management interface

Parameters:
  • device_map (object) – dictionary of low level DeviceProvider intances

  • root_dir (str) – root directory path name

  • volumes (list) – list of volumes from XMLState::get_volumes()

  • custom_args (dict) – custom volume manager arguments for all volume manager and filesystem specific tasks

Raises:

KiwiVolumeManagerSetupError – if the given root_dir doesn’t exist

apply_attributes_on_volume(toplevel, volume)[source]
create_verification_metadata(device_node: str = '') None[source]

Write verification block on LVM devices is not supported

create_verity_layer(blocks: int | None = None, filename: str | None = None)[source]

veritysetup on LVM devices is not supported

create_volume_paths_in_root_dir()[source]

Implements creation of volume paths in the given root directory

create_volumes(filesystem_name)[source]

Implements creation of volumes

Implementation in specialized volume manager class required

Parameters:

filesystem_name (str) – unused

custom_args: Dict[str, Any]

custom arguments passed to setup the volumes

custom_filesystem_args: Dict[str, Any]

custom filesystem creation and mount arguments, subset of the custom_args information suitable to be passed to a FileSystem instance

device

main storage device node name

device_map

dictionary of mapped DeviceProviders

device_provider_root

the underlaying device provider

get_canonical_volume_list()[source]

Implements hierarchical sorting of volumes according to their paths and provides information about the volume configured as the one eating all the rest space

Returns:

list of canonical_volume_type tuples

Return type:

list

get_device()[source]

Return current DeviceProvider dictionary

Returns:

device_map

Return type:

dict

get_fstab(persistency_type: str, filesystem_name: str) List[str][source]

Implements setup of the fstab entries. The method should return a list of fstab compatible entries

Parameters:
  • persistency_type (str) – unused

  • filesystem_name (str) – unused

get_mountpoint() str | None[source]

Provides mount point directory

Effective use of the directory is guaranteed only after sync_data

Returns:

directory path name

Return type:

string

get_root_volume_name() str[source]

Provides name of the root volume

This is by default set to ‘/’. Volume Managers that supports the concept of sub-volumes overrides this method

Returns:

directory path name

Return type:

string

get_volume_mbsize(volume, all_volumes, filesystem_name, resize_on_boot=False) int[source]

Implements size lookup for the given path and desired filesystem according to the specified size type

Parameters:
  • volume (tuple) – volume to check size for

  • all_volumes (list) – list of all volume tuples

  • filesystem_name (str) – filesystem name

  • resize_on_boot – specify the time of the resize. If the resize happens at boot time the volume size is only the minimum size to just store the data. If the volume size is fixed and does not change at boot time the returned size is the requested size which can be greater than the minimum needed size.

Returns:

mbsize

Return type:

int

get_volumes()[source]

Implements return of dictionary of volumes and their mount options

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 volume manager is it too

Returns:

True of False

Return type:

bool

mount()[source]

Consistency layer with regards to FileSystem classes

Invokes mount_volumes

mount_list: List[MountManager]

list of volume MountManager’s

mount_volumes()[source]

Implements mounting of all volumes below one master directory

Implementation in specialized volume manager class required

mountpoint: str | None

all volumes are combined into one mountpoint. This is needed at sync_data time. How to mount the volumes is special to the volume management class

post_init(custom_args)[source]

Post initialization method

Implementation in specialized volume manager class if required

Parameters:

custom_args (dict) – unused

root_dir

root directory path name

set_property_readonly_root()[source]

Implements setup of read-only root property

setup(name: str | None = None)[source]

Implements setup required prior to the creation of volumes

Implementation in specialized volume manager class required

Parameters:

name (str) – unused

setup_mountpoint()[source]

Implements creation of a master directory holding the mounts of all volumes

sync_data(exclude: List[str] | None = None) MountManager | None[source]

Implements sync of root directory to mounted volumes

Parameters:

exclude (list) – file patterns to exclude

Returns:

If a mount was created, then a context manager implementing the unmount is returned.

umount()[source]

Consistency layer with regards to FileSystem classes

Invokes umount_volumes

umount_volumes()[source]

Implements umounting of all volumes

Implementation in specialized volume manager class required

volume_group

volume group name

volume_map: Dict[str, str]

map volume name to device node

volumes

list of volumes from XMLState::get_volumes()

kiwi.volume_manager.btrfs Module

class kiwi.volume_manager.btrfs.VolumeManagerBtrfs(device_map: Dict[str, DeviceProvider], root_dir: str, volumes: List[volume_type], custom_args: Dict[str, Any] | None = None)[source]

Bases: VolumeManagerBase

Implements btrfs sub-volume management

Parameters:
  • subvol_mount_list (list) – list of mounted btrfs subvolumes

  • toplevel_mount (object) – MountManager for root mountpoint

create_volumes(filesystem_name)[source]

Create configured btrfs subvolumes

Any btrfs subvolume is of the same btrfs filesystem. There is no way to have different filesystems per btrfs subvolume. Thus the filesystem_name has no effect for btrfs

Parameters:

filesystem_name (string) – unused

get_fstab(persistency_type: str = 'by-label', filesystem_name: str = '') List[str][source]

Implements creation of the fstab entries. The method returns a list of fstab compatible entries

Parameters:
  • persistency_type (string) – by-label | by-uuid

  • filesystem_name (string) – unused

Returns:

list of fstab entries

Return type:

list

get_mountpoint() str[source]

Provides btrfs root mount point directory

Effective use of the directory is guaranteed only after sync_data

Returns:

directory path name

Return type:

string

get_root_volume_name() str[source]

Provides name of the root volume

Returns:

directory path name

Return type:

string

get_volumes()[source]

Return dict of volumes

Returns:

volumes dictionary

Return type:

dict

mount_volumes()[source]

Mount btrfs subvolumes

post_init(custom_args)[source]

Post initialization method

Store custom btrfs initialization arguments

Parameters:

custom_args (dict) – custom btrfs volume manager arguments

set_property_readonly_root()[source]

Sets the root volume to be a readonly filesystem

setup(name=None)[source]

Setup btrfs volume management

In case of btrfs an optional toplevel subvolume is created and marked as default volume. If snapshots are activated via the custom_args the setup method also creates the .snapshots/1/snapshot subvolumes. There is no concept of a volume manager name, thus the name argument is not used for btrfs

Parameters:

name (string) – unused

sync_data(exclude=None)[source]

Sync data into btrfs filesystem

If snapshots are activated the root filesystem is synced into the first snapshot

Parameters:

exclude (list) – files to exclude from sync

umount_volumes() None[source]

Umount btrfs subvolumes

kiwi.volume_manager.lvm Module

class kiwi.volume_manager.lvm.VolumeManagerLVM(device_map: Dict[str, DeviceProvider], root_dir: str, volumes: List[volume_type], custom_args: Dict[str, Any] | None = None)[source]

Bases: VolumeManagerBase

Implements LVM volume management

create_volumes(filesystem_name)[source]

Create configured lvm volumes and filesystems

All volumes receive the same filesystem

Parameters:

filesystem_name (str) – volumes filesystem name

get_device()[source]

Dictionary of MappedDevice instances per volume

Note: The mapping requires an explicit create_volumes() call

Returns:

root plus volume device map

Return type:

dict

get_fstab(persistency_type: str = 'by-label', filesystem_name: str = '') List[str][source]

Implements creation of the fstab entries. The method returns a list of fstab compatible entries

Parameters:
  • persistency_type (str) – unused

  • filesystem_name (str) – volumes filesystem name

Returns:

fstab entries

Return type:

list

get_volumes() Dict[source]

Return dict of volumes

Returns:

volumes dictionary

Return type:

dict

mount_volumes()[source]

Mount lvm volumes

post_init(custom_args)[source]

Post initialization method

Store custom lvm initialization arguments

Parameters:

custom_args (list) – custom lvm volume manager arguments

setup(volume_group_name='systemVG')[source]

Setup lvm volume management

In case of LVM a new volume group is created on a PV initialized storage device

Parameters:

name (str) – volume group name

umount_volumes()[source]

Umount lvm volumes

Module Contents

class kiwi.volume_manager.VolumeManager[source]

Bases: object

VolumeManager factory

Parameters:
  • name (str) – volume management name

  • device_map (dict) – dictionary of low level DeviceProvider intances

  • root_dir (str) – root directory path name

  • volumes (list) – list of volumes from XMLState::get_volumes()

  • custom_args (dict) – dictionary of custom volume manager arguments

static new(name: str, device_map: object, root_dir: str, volumes: List, custom_args: Dict | None = None)[source]