blivet.formats package

Submodules

blivet.formats.biosboot module

class blivet.formats.biosboot.BIOSBoot(*args, **kwargs)

Bases: DeviceFormat

BIOS boot partition for GPT disklabels.

Parameters:
  • device (str) – path to the block device node

  • exists (bool) – whether the formatting exists

Note

The ‘device’ kwarg is required for existing formats.

parted_flag = 12
property status

Return an attribute of instance, which is of type owner.

property supported

Return an attribute of instance, which is of type owner.

blivet.formats.disklabel module

class blivet.formats.disklabel.DiskLabel(*args, **kwargs)

Bases: DeviceFormat

Disklabel

Parameters:
  • device (str) – full path to the block device node

  • uuid (str) – disklabel UUID

  • label_type (str) – type of disklabel to create

  • exists (bool) – whether the formatting exists

add_partition(start, end, ptype=None, part_type_uuid=None)

Add a partition to the disklabel.

Parameters:
  • start (int) – start sector

  • end (int) – end sector

  • ptype (int (parted partition type constant) or NoneType) – partition type or None

  • part_type_uuid (uuid.UUID or NoneType) – partition type UUID or None

:raises PartitioningError: if parted is too old to

support partition type UUIDs

Partition type will default to either PARTITION_NORMAL or PARTITION_LOGICAL, depending on whether the start sector is within an extended partition.

property alignment

Return an attribute of instance, which is of type owner.

commit()

Commit the current partition table to disk and notify the OS.

commit_to_disk()

Commit the current partition table to disk.

property desc

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

property end_alignment

Return an attribute of instance, which is of type owner.

property extended_partition

Return an attribute of instance, which is of type owner.

property first_partition

Return an attribute of instance, which is of type owner.

property free

Return an attribute of instance, which is of type owner.

fresh_parted_disk()

Return a new, empty parted.Disk instance for this device.

get_alignment(size=None)

Return an appropriate alignment for a new partition.

Parameters:

size (Size) – proposed partition size (optional)

Returns:

the appropriate alignment to use

Return type:

parted.Alignment

:raises AlignmentError: if the partition is too

small to be aligned

get_end_alignment(size=None, alignment=None)

Return an appropriate end-alignment for a new partition.

Parameters:
  • size (Size) – proposed partition size (optional)

  • alignment (parted.Alignment) – the start alignment (optional)

Returns:

the appropriate alignment to use

Return type:

parted.Alignment

:raises AlignmentError: if the partition is too

small to be aligned

get_minimal_alignment()

Return the device’s minimal alignment for new partitions.

Return type:

parted.Alignment

get_optimal_alignment()

Return the device’s optimal alignment for new partitions.

Return type:

parted.Alignment

Note

If there is no device-supplied optimal alignment this method returns the minimal device alignment.

classmethod get_platform_label_types()
property label_type

The disklabel type (eg: ‘gpt’, ‘msdos’)

property logical_partitions

Return an attribute of instance, which is of type owner.

property magic_partition_number

Number of disklabel-type-specific special partition.

property name

Return an attribute of instance, which is of type owner.

property parted_device

Return an attribute of instance, which is of type owner.

property parted_disk

Return an attribute of instance, which is of type owner.

property partitions

Return an attribute of instance, which is of type owner.

property primary_partitions

Return an attribute of instance, which is of type owner.

remove_partition(partition)

Remove a partition from the disklabel.

Parameters:

partition (parted.Partition) – the partition to remove

reset_parted_disk()

Set this instance’s parted_disk to reflect the disk’s contents.

property sector_size

Return an attribute of instance, which is of type owner.

classmethod set_default_label_type(labeltype)
property size

Return an attribute of instance, which is of type owner.

property status

Device status.

property supported

Return an attribute of instance, which is of type owner.

property supports_names

Return an attribute of instance, which is of type owner.

update_orig_parted_disk()
update_parted_disk()

re-read the disklabel from the device

blivet.formats.dmraid module

class blivet.formats.dmraid.DMRaidMember(*args, **kwargs)

Bases: DeviceFormat

A dmraid member disk.

Parameters:
  • device (str) – The path to the device node.

  • uuid (str) – the formatting’s UUID.

  • exists – Whether the formatting exists. (default: False)

Raises:

ValueError

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

create(**kwargs)

Write the formatting to the specified block device.

Parameters:

device (str.) – path to device node

Raises:

FormatCreateError

Returns:

None.

destroy(**kwargs)

Remove the formatting from the associated block device.

Raises:

FormatDestroyError

Returns:

None.

blivet.formats.fs module

Filesystem classes.

class blivet.formats.fs.BTRFS(*args, **kwargs)

Bases: FS

btrfs filesystem

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property container_uuid

Return an attribute of instance, which is of type owner.

create(**kwargs)

Write the formatting to the specified block device.

Parameters:

device (str.) – path to device node

Raises:

FormatCreateError

Returns:

None.

destroy(**kwargs)

Remove the formatting from the associated block device.

Raises:

FormatDestroyError

Returns:

None.

property is_empty

Check whether this filesystem os empty or not

Note: If the filesystem is not mounted, this will temporarily mount it

to a temporary directory.

class blivet.formats.fs.BindFS(*args, **kwargs)

Bases: FS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.DevPtsFS(*args, **kwargs)

Bases: NoDevFS

devpts filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.EFIFS(*args, **kwargs)

Bases: FATFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_flag = 1
property supported

Return an attribute of instance, which is of type owner.

class blivet.formats.fs.EFIVarFS(*args, **kwargs)

Bases: NoDevFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.ExFATFS(*args, **kwargs)

Bases: FS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.Ext2FS(*args, **kwargs)

Bases: FS

ext2 filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_system = <_ped.FileSystemType object>
class blivet.formats.fs.Ext3FS(*args, **kwargs)

Bases: Ext2FS

ext3 filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_system = <_ped.FileSystemType object>
class blivet.formats.fs.Ext4FS(*args, **kwargs)

Bases: Ext3FS

ext4 filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_system = <_ped.FileSystemType object>
class blivet.formats.fs.F2FS(*args, **kwargs)

Bases: FS

f2fs filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.FATFS(*args, **kwargs)

Bases: FS

FAT filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

generate_new_uuid()

Generate a new random UUID in the RFC 4122 format.

Return type:

str

parted_system = <_ped.FileSystemType object>
class blivet.formats.fs.FS(*args, **kwargs)

Bases: DeviceFormat

Filesystem base class.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

classmethod biggest_overhead_FS(fs_list=None)

Get format class from list of format classes with largest space taken by metadata.

Parameters:

fs_list (list of classes with parent FS) – list of input filesystems

Returns:

FS which takes most space by metadata

can_modify_uuid()

Returns True if it’s possible to set the UUID of this filesystem after it has been created, otherwise False.

Return type:

bool

can_nodiscard()

Returns True if this filesystem supports nodiscard option during creation, otherwise False.

Return type:

bool

can_set_uuid()

Returns True if this filesystem supports setting an UUID during creation, otherwise False.

Return type:

bool

change_mountpoint(dry_run=False)
check_module()

Check if kernel module required to support this filesystem is available.

config_actions_map = {'label': 'write_label', 'mountpoint': 'change_mountpoint'}
property controllable

Return an attribute of instance, which is of type owner.

property desc

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

do_check()

Run a filesystem check.

Raises:

FSError

property formattable

Return an attribute of instance, which is of type owner.

property free

The amount of space that can be gained by resizing this filesystem to its minimum size.

classmethod free_space_estimate(device_size)

Get estimated free space when format will be done on device with size device_size.

Note

This is more guess than precise number. To get precise space taken the FS must provide this number to us.

Parameters:

device_size (Size object) – original device size

Returns:

estimated free size after format

Return type:

Size

generate_new_uuid()

Generate a new random UUID in the RFC 4122 format.

Return type:

str

classmethod get_required_size(free_space)

Get device size we need to get a free_space on the device. This calculation will add metadata to usable device on the FS.

Note

This is more guess than precise number. To get precise space taken the FS must provide this number to us.

Parameters:

free_space (Size object) – how much usable size we want on newly created device

Returns:

estimated size of the device which will have given amount of free_space

Return type:

Size

property is_empty

Check whether this filesystem os empty or not

Note: If the filesystem is not mounted, this will temporarily mount it

to a temporary directory.

property label

this filesystem’s label

label_format_ok(label)

Return True if the label has an acceptable format for this filesystem. None, which represents accepting the default for this device, is always acceptable.

Parameters:

label (str or None) – A possible label

labeling()

Returns True if this filesystem uses labels, otherwise False.

Return type:

bool

mount(**kwargs)

Mount this filesystem.

keyword options:

mount options (overrides all other option strings)

type options:

str.

keyword chroot:

prefix to apply to mountpoint

keyword mountpoint:

mountpoint (overrides self.mountpoint)

raises:

FSError

Note

When mounted multiple times the unmount method needs to be called with a specific mountpoint to unmount, otherwise it will try to unmount the most recent one listed by the system.

property mount_type

Return an attribute of instance, which is of type owner.

property mountable

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
read_label()

Read this filesystem’s label.

Returns:

the filesystem’s label

Return type:

str

Raises a FSReadLabelError if the label can not be read.

relabels()

Returns True if it is possible to relabel this filesystem after creation, otherwise False.

Return type:

bool

reset_uuid()

Generate a new UUID for the file system and set/write it.

property resizable

Can formats of this filesystem type be resized?

property status

Return an attribute of instance, which is of type owner.

property supported

Return an attribute of instance, which is of type owner.

sync(root='/')

Ensure that data we’ve written is at least in the journal.

This is a little odd because xfs_freeze will only be available under the install root.

property system_mountpoint

Get current mountpoint

returns: mountpoint rtype: str or None

If there are multiple mountpoints it returns the most recent one.

test_mount()

Try to mount the fs and return True if successful.

unmount(**kwargs)

Unmount this filesystem.

Parameters:

mountpoint (str) – Optional mountpoint to be unmounted.

Raises:

FSError

If mountpoint isn’t passed this will unmount the most recent mountpoint listed by the system. Override this behavior by passing a specific mountpoint. FSError will be raised in either case if the path doesn’t exist.

update_size_info()

Update this filesystem’s current and minimum size (for resize).

property utils_available

Return an attribute of instance, which is of type owner.

uuid_format_ok(uuid)

Return True if the UUID has an acceptable format for this filesystem.

Parameters:

uuid (str) – An UUID

write_label(dry_run=False)

Create a label for this filesystem.

Raises:

FSError

If self.label is None, this means accept the default, so raise an FSError in this case.

Raises a FSError if the label can not be set.

write_uuid()

Set an UUID for this filesystem.

Raises:

FSError

Raises an FSError if the UUID can not be set.

class blivet.formats.fs.GFS2(*args, **kwargs)

Bases: FS

gfs2 filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property supported

Is this filesystem a supported type?

class blivet.formats.fs.HFS(*args, **kwargs)

Bases: FS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.HFSPlus(*args, **kwargs)

Bases: FS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_system = <_ped.FileSystemType object>
class blivet.formats.fs.Iso9660FS(*args, **kwargs)

Bases: FS

ISO9660 filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.JFS(*args, **kwargs)

Bases: FS

JFS filesystem

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.MacEFIFS(*args, **kwargs)

Bases: HFSPlus

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property supported

Return an attribute of instance, which is of type owner.

class blivet.formats.fs.NFS(*args, **kwargs)

Bases: FS

NFS filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.NFSv4(*args, **kwargs)

Bases: NFS

NFSv4 filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.NTFS(*args, **kwargs)

Bases: FS

ntfs filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

generate_new_uuid()

Generate a new random UUID in the RFC 4122 format.

Return type:

str

parted_system = <_ped.FileSystemType object>
class blivet.formats.fs.NoDevFS(*args, **kwargs)

Bases: FS

nodev filesystem base class

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property type

Return an attribute of instance, which is of type owner.

class blivet.formats.fs.ProcFS(*args, **kwargs)

Bases: NoDevFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.ReiserFS(*args, **kwargs)

Bases: FS

reiserfs filesystem

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.SELinuxFS(*args, **kwargs)

Bases: NoDevFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.StratisXFS(*args, **kwargs)

Bases: XFS

XFS on top of Stratis filesystem device

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.SysFS(*args, **kwargs)

Bases: NoDevFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.TmpFS(*args, **kwargs)

Bases: NoDevFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

create(**kwargs)

A filesystem is created automatically once tmpfs is mounted.

destroy(**kwargs)

The device and its filesystem are automatically destroyed once the mountpoint is unmounted.

do_resize()

Resize this filesystem based on this instance’s target_size attr.

Raises:

FSResizeError, FormatResizeError

property free

Return an attribute of instance, which is of type owner.

class blivet.formats.fs.UDFFS(*args, **kwargs)

Bases: FS

UDF filesystem.

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.USBFS(*args, **kwargs)

Bases: NoDevFS

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.fs.XFS(*args, **kwargs)

Bases: FS

XFS filesystem

Parameters:
  • device – path to the block device node (required for existing filesystems)

  • mountpoint – the filesystem’s planned mountpoint

  • label – the filesystem label

  • uuid – the filesystem UUID

  • mountopts (str) – mount options for the filesystem

  • size – the filesystem’s size in MiB

  • exists (bool) – indicates whether this is an existing filesystem

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_system = <_ped.FileSystemType object>
write_uuid()

Set an UUID for this filesystem.

Raises:

FSError

Raises an FSError if the UUID can not be set.

blivet.formats.fslib module

class blivet.formats.fslib.FSResize

Bases: object

OFFLINE_GROW = 4
OFFLINE_SHRINK = 2
ONLINE_GROW = 16
ONLINE_SHRINK = 8
blivet.formats.fslib.update_kernel_filesystems()

blivet.formats.luks module

class blivet.formats.luks.BitLocker(*args, **kwargs)

Bases: DeviceFormat

DM integrity format

Parameters:
  • device (str) – The path to the device node.

  • uuid (str) – the formatting’s UUID.

  • exists – Whether the formatting exists. (default: False)

Raises:

ValueError

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

class blivet.formats.luks.Integrity(*args, **kwargs)

Bases: DeviceFormat

DM integrity format

Parameters:
  • device – the path to the underlying device

  • exists (bool) – indicates whether this is an existing format

  • name – the name of the mapped device

  • algorithm – integrity algorithm (HMAC is not supported)

  • sector_size (int) – integrity sector size

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property formattable

Return an attribute of instance, which is of type owner.

property status

Return an attribute of instance, which is of type owner.

class blivet.formats.luks.LUKS(*args, **kwargs)

Bases: DeviceFormat

Parameters:
  • device – the path to the underlying device

  • uuid – the LUKS UUID

  • exists (bool) – indicates whether this is an existing format

  • name – the name of the mapped device

  • passphrase (str) – device passphrase

  • key_file (str) – path to a file containing a key

  • cipher (str) – cipher mode

  • key_size (int) – key size in bits

  • escrow_cert (str) – certificate (contents) to use for key escrow

  • add_backup_passphrase (bool.) – generate a backup passphrase?

  • min_luks_entropy (int) – minimum entropy in bits required for format creation

  • luks_version (str) – luks format version (“luks1” or “luks2”)

  • pbkdf_args (LUKS2PBKDFArgs) – optional arguments for LUKS2 key derivation function (for non-existent format only)

  • luks_sector_size (int) – encryption sector size (use only with LUKS version 2)

  • subsystem (str) – LUKS subsystem

  • opal_admin_passphrase (str) – OPAL admin passphrase

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

add_passphrase(passphrase)

Add a new passphrase.

Add the specified passphrase to an available key slot in the LUKS header.

property configured

To be ready we need a key or passphrase and a map name.

property controllable

Return an attribute of instance, which is of type owner.

property destroyable

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

escrow(directory, backup_passphrase)
property formattable

Return an attribute of instance, which is of type owner.

property has_key

Return an attribute of instance, which is of type owner.

property key_file

Path to key file to be used in /etc/crypttab

property name

Return an attribute of instance, which is of type owner.

property opal_admin_passphrase

Return an attribute of instance, which is of type owner.

property passphrase

Return an attribute of instance, which is of type owner.

populate_ksdata(data)
property protected

Return an attribute of instance, which is of type owner.

remove_passphrase()

Remove the saved passphrase (and possibly key file) from the LUKS header.

Note: If both passphrase and keyfile are set for this format, both

will be removed!

property resizable

Return an attribute of instance, which is of type owner.

property status

Return an attribute of instance, which is of type owner.

property supported

Return an attribute of instance, which is of type owner.

update_size_info()

Update this format’s current size.

class blivet.formats.luks.LUKS2PBKDFArgs(type=None, max_memory_kb=0, iterations=0, time_ms=0, hash_fn=None)

Bases: object

PBKDF arguments for LUKS 2 format

blivet.formats.lvmpv module

class blivet.formats.lvmpv.LVMPhysicalVolume(*args, **kwargs)

Bases: DeviceFormat

An LVM physical volume.

Parameters:
  • device – path to the block device node

  • uuid – this PV’s uuid (not the VG uuid)

  • exists (bool) – indicates whether this is an existing format

  • vg_name – the name of the VG this PV belongs to

  • vg_uuid – the UUID of the VG this PV belongs to

  • pe_start (Size) – offset of first physical extent

  • data_alignment (Size) – data alignment (for non-existent PVs)

  • free (Size) – free space in the PV

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property container_uuid

Return an attribute of instance, which is of type owner.

property destroyable

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

property formattable

Return an attribute of instance, which is of type owner.

property free

Information about the free space in this PV

property grow_to_fill

Can be set to True to mark format for resize so it matches size of its device. (Main usecase is disk size increase on VM) Uses blockdev/lvm for exact new size calculation. ActionResizeFormat has to be executed to apply the change. Format has to be resizable (i.e. run format.update_size_info() first) to allow this.

lvmdevices_add(force=True)

Add this PV to the LVM system devices file :keyword force: whether to add the PV even if the system devices file doesn’t exist and

VGs are present in the system

lvmdevices_remove()
parted_flag = 6
property status

Return an attribute of instance, which is of type owner.

property supported

Return an attribute of instance, which is of type owner.

update_size_info()

Update this format’s current size.

blivet.formats.mdraid module

class blivet.formats.mdraid.MDRaidMember(*args, **kwargs)

Bases: DeviceFormat

An mdraid member disk.

Parameters:
  • device – path to block device node

  • uuid – this member device’s uuid

  • exists (bool) – whether this is an existing format

  • md_uuid – the uuid of the array this device belongs to

Note

The ‘device’ kwarg is required for existing formats.

property container_uuid

Return an attribute of instance, which is of type owner.

property destroyable

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

property formattable

Return an attribute of instance, which is of type owner.

property hidden

Return an attribute of instance, which is of type owner.

parted_flag = 5
property status

Return an attribute of instance, which is of type owner.

property supported

Return an attribute of instance, which is of type owner.

blivet.formats.multipath module

class blivet.formats.multipath.MultipathMember(*args, **kwargs)

Bases: DeviceFormat

A multipath member disk.

Parameters:
  • device – path to the underlying device (required)

  • uuid – this format’s UUID

  • exists (bool) – whether this is an existing format

create(**kwargs)

Write the formatting to the specified block device.

Parameters:

device (str.) – path to device node

Raises:

FormatCreateError

Returns:

None.

destroy(**kwargs)

Remove the formatting from the associated block device.

Raises:

FormatDestroyError

Returns:

None.

property member

Return an attribute of instance, which is of type owner.

blivet.formats.prepboot module

class blivet.formats.prepboot.PPCPRePBoot(*args, **kwargs)

Bases: DeviceFormat

Generic device format.

Parameters:
  • device – path to block device node

  • exists (bool) – whether this is an existing format

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

parted_flag = 10
property status

Return an attribute of instance, which is of type owner.

property supported

Return an attribute of instance, which is of type owner.

blivet.formats.stratis module

class blivet.formats.stratis.StratisBlockdev(*args, **kwargs)

Bases: DeviceFormat

A Stratis block device

Parameters:
  • device – path to the block device node

  • uuid – this Stratis block device UUID (not the pool UUID)

  • exists (bool) – indicates whether this is an existing format

  • pool_name – the name of the pool this block device belongs to

  • pool_uuid – the UUID of the pool this block device belongs to

  • locked_pool (bool) – whether this block device belongs to a locked pool or not

  • locked_pool_key_desc (str) – kernel keyring description for locked pool

  • passphrase (str) – passphrase for the locked pool

  • key_file (str) – path to a file containing a key

  • locked_pool_clevis_pin (str) – clevis PIN for locked pool (either ‘tang’ or ‘tpm’)

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property dict

Return an attribute of instance, which is of type owner.

property has_key

Return an attribute of instance, which is of type owner.

property key_file

Path to key file to be used in /etc/crypttab

property passphrase

Return an attribute of instance, which is of type owner.

property status

Return an attribute of instance, which is of type owner.

unlock_pool()

blivet.formats.swap module

class blivet.formats.swap.SwapSpace(*args, **kwargs)

Bases: DeviceFormat

Swap space

Parameters:
  • device – path to the block device node

  • uuid – this swap space’s uuid

  • exists (bool) – whether this is an existing format

  • label – this swap space’s label

  • priority (int) – this swap space’s priority

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the ‘device’ attribute be set before the create() method runs. You can specify the device at the last moment by via the ‘device’ kwarg to the create() method.

config_actions_map = {'label': 'write_label'}
property controllable

Return an attribute of instance, which is of type owner.

property dict

Return an attribute of instance, which is of type owner.

property formattable

Return an attribute of instance, which is of type owner.

property label

the label for this swap space

label_format_ok(label)

Check whether the given label is correct (16 characters or shorter).

labeling()

Returns True as mkswap can write a label to the swap space.

parted_flag = 3
parted_system = <_ped.FileSystemType object>
property priority

The priority of the swap device

relabels()

Returns True as mkswap can write a label to the swap space.

property status

Device status.

property supported

Return an attribute of instance, which is of type owner.

uuid_format_ok(uuid)

Check whether the given UUID is correct according to RFC 4122.

write_label(dry_run=False)

Create a label for this format.

Raises:

SwapSpaceError

If self.label is None, this means accept the default, so raise an SwapSpaceError in this case.

Raises a SwapSpaceError if the label can not be set.

Module contents

class blivet.formats.DeviceFormat(*args, **kwargs)

Bases: ObjectID

Generic device format.

This represents the absence of recognized formatting. That could mean a device is uninitialized, has had zeros written to it, or contains some valid formatting that this module does not support.

Parameters:
  • device (str) – The path to the device node.

  • uuid (str) – the formatting’s UUID.

  • exists – Whether the formatting exists. (default: False)

Raises:

ValueError

Note

The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the device attribute be set before the create() method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to the create() method.

property check

Whether or not this format is checked on boot.

property controllable

Are external utilities available to allow this format to be both setup and teared down.

Returns:

True if this format can be set up, otherwise False

Return type:

bool

create(**kwargs)

Write the formatting to the specified block device.

Parameters:

device (str.) – path to device node

Raises:

FormatCreateError

Returns:

None.

property create_options

options to be used when running mkfs

property current_size

The filesystem’s current actual size.

property desc

Return an attribute of instance, which is of type owner.

destroy(**kwargs)

Remove the formatting from the associated block device.

Raises:

FormatDestroyError

Returns:

None.

property destroyable

Do we have the facilities to destroy a format of this type.

property device

Full path the device this format occupies

property dict

Return an attribute of instance, which is of type owner.

do_resize()

Resize this filesystem based on this instance’s target_size attr.

Raises:

FSResizeError, FormatResizeError

property dump

Whether or not this format will be dumped by dump(8).

property formattable

Can we create formats of this type?

property hidden

Whether devices with this formatting should be hidden in UIs.

property ks_mountpoint

Return an attribute of instance, which is of type owner.

label_format_ok(label)

Checks whether the format of the label is OK for whatever application is used by blivet to write a label for this format. If there is no application that blivet uses to write a label, then no format is acceptable, so must return False.

Parameters:

label (str) – The label to be checked

Return type:

bool

Returns:

True if the format of the label is OK, otherwise False

labeling()

Returns False by default since most formats are non-labeling.

property linux_native

Is this format type native to linux?

property max_size

Maximum size for this format type.

property min_size

Return an attribute of instance, which is of type owner.

property mountable

Is this something we can mount?

property name

Return an attribute of instance, which is of type owner.

property options

fstab entry option string

property packages

Packages required to manage formats of this type.

parted_flag = None
parted_system = None
populate_ksdata(data)
property protected

Is this format protected?

relabels()

Returns False by default since most formats are non-labeling.

property resizable

Can formats of this type be resized?

setup(**kwargs)

Activate the formatting.

Parameters:

device (str.) – device node path

Raises:

FormatSetupError.

Returns:

None.

property size

This filesystem’s size, accounting for pending changes

property status

Return an attribute of instance, which is of type owner.

property supported

Is this format a supported type?

Are the necessary external applications required by the functionality that this format provides actually provided by the environment in which blivet is running?

property target_size

Target size for this filesystem

teardown(**kwargs)

Deactivate the formatting.

property type

Return an attribute of instance, which is of type owner.

update_size_info()

Update this format’s current and minimum size (for resize).

blivet.formats.get_default_filesystem_type()
blivet.formats.get_device_format_class(fmt_type)

Return an appropriate format class.

Parameters:

fmt_type (str.) – The name of the format type.

Returns:

The chosen DeviceFormat class

Return type:

class.

Returns None if no class is found for fmt_type.

blivet.formats.get_format(fmt_type, *args, **kwargs)

Return an instance of the appropriate DeviceFormat class.

Parameters:

fmt_type (str.) – The name of the formatting type

Returns:

the format instance

Return type:

DeviceFormat

Raises:

ValueError

Note

Any additional arguments will be passed on to the constructor for the format class. See the various DeviceFormat subclasses for an exhaustive list of the arguments that can be passed.

blivet.formats.register_device_format(fmt_class)