progfiguration.localhost.disks#

Working with disks, filesystems, etc

Module Contents#

Classes#

FilesystemSpec

WholeDiskSpec

A specification for a whole disk, to give an unpartitioned disk either a filesystem or a volume group

PartitionSpec

A specification for a single partition

LvmLvSpec

A specification for an LVM logical volume

Functions#

cryptsetup_open_idempotently(device, keyfile, lukslabel)

Use cryptsetup to open a device idempotently

gptlabel2device(→ str)

Given a GPT partition label, return a path representing the partition device.

is_mountpoint(→ bool)

Return true if a path is a mountpoint for a currently mounted filesystem

class progfiguration.localhost.disks.FilesystemSpec#
fstype: str#
label: str#
label_flag: str = '-L'#
options: List[str]#
class progfiguration.localhost.disks.WholeDiskSpec#

A specification for a whole disk, to give an unpartitioned disk either a filesystem or a volume group

device: str#
filesystem: FilesystemSpec | None#
volgroup: str | None#
encrypt: bool = False#
encrypt_label: str | None#
__post_init__()#
class progfiguration.localhost.disks.PartitionSpec#

A specification for a single partition

device: str#
label: str#
start: str#
end: str#
filesystem: FilesystemSpec | None#
volgroup: str | None#
encrypt: bool = False#
__post_init__()#
class progfiguration.localhost.disks.LvmLvSpec#

A specification for an LVM logical volume

property device: str#
name: str#
volgroup: str#
size: str#
filesystem: FilesystemSpec | None#
exception progfiguration.localhost.disks.NoDeviceFoundWithPartitionLabelError#

Bases: Exception

Common base class for all non-exit exceptions.

exception progfiguration.localhost.disks.InvalidBlockDeviceSpecError#

Bases: Exception

Common base class for all non-exit exceptions.

exception progfiguration.localhost.disks.MissingVolumeGroupError#

Bases: Exception

Common base class for all non-exit exceptions.

exception progfiguration.localhost.disks.DuplicatePartitionLabelError#

Bases: Exception

Common base class for all non-exit exceptions.

exception progfiguration.localhost.disks.EncryptionKeyfileNotFoundError#

Bases: Exception

Common base class for all non-exit exceptions.

exception progfiguration.localhost.disks.EncryptionKeyfileNotSetError#

Bases: Exception

Common base class for all non-exit exceptions.

progfiguration.localhost.disks.cryptsetup_open_idempotently(device: str, keyfile: str, lukslabel: str)#

Use cryptsetup to open a device idempotently

progfiguration.localhost.disks.gptlabel2device(label: str) str#

Given a GPT partition label, return a path representing the partition device.

Note that GPT partition labels are NOT filesystem labels made with e2label.

Under udev, we can find this easily via /dev/disk/by-label/$LABELNAME, but using the mdev with Alpine’s default rules, that will not exist, so we have to do it this way.

progfiguration.localhost.disks.is_mountpoint(path: str) bool#

Return true if a path is a mountpoint for a currently mounted filesystem