blivet.formats package¶
Submodules¶
blivet.formats.biosboot module¶
- class blivet.formats.biosboot.BIOSBoot(*args, **kwargs)¶
Bases:
DeviceFormatBIOS boot partition for GPT disklabels.
- Parameters:
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:
DeviceFormatDisklabel
- Parameters:
- add_partition(start, end, ptype=None, part_type_uuid=None)¶
Add a partition to the disklabel.
- Parameters:
- :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.
- drop_cache()¶
Drop cached information stored for this format
- 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:
DeviceFormatA dmraid member disk.
- Parameters:
- Raises:
ValueError
Note
The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
FSbtrfs 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.DevPtsFS(*args, **kwargs)¶
Bases:
NoDevFSdevpts 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.Ext2FS(*args, **kwargs)¶
Bases:
FSext2 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- parted_system = <_ped.FileSystemType object>¶
- class blivet.formats.fs.Ext3FS(*args, **kwargs)¶
Bases:
Ext2FSext3 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- parted_system = <_ped.FileSystemType object>¶
- class blivet.formats.fs.Ext4FS(*args, **kwargs)¶
Bases:
Ext3FSext4 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- parted_system = <_ped.FileSystemType object>¶
- class blivet.formats.fs.F2FS(*args, **kwargs)¶
Bases:
FSf2fs 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.FATFS(*args, **kwargs)¶
Bases:
FSFAT 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- parted_system = <_ped.FileSystemType object>¶
- class blivet.formats.fs.FS(*args, **kwargs)¶
Bases:
DeviceFormatFilesystem 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
- can_nodiscard()¶
Returns True if this filesystem supports nodiscard option during creation, otherwise False.
- Return type:
- can_set_uuid()¶
Returns True if this filesystem supports setting an UUID during creation, otherwise False.
- Return type:
- 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.
- classmethod get_required_size(free_space)¶
Get device size we need to get a
free_spaceon 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.
- 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
- 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:
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:
- 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=None)¶
Ensure that data we’ve written is at least in the journal.
Note
Note the :root: parameter is ignored, this is a relic from previous version that used xfs_freeze which needed to be run from chroot, this was since changed and we are using the FIFREEZE/FITHAW ioctls directly without chroot.
- 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:
FSgfs2 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- parted_system = <_ped.FileSystemType object>¶
- class blivet.formats.fs.Iso9660FS(*args, **kwargs)¶
Bases:
FSISO9660 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.JFS(*args, **kwargs)¶
Bases:
FSJFS 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- property supported¶
Return an attribute of instance, which is of type owner.
- class blivet.formats.fs.NFS(*args, **kwargs)¶
Bases:
FSNFS 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.NFSv4(*args, **kwargs)¶
Bases:
NFSNFSv4 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.NTFS(*args, **kwargs)¶
Bases:
FSntfs 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- parted_system = <_ped.FileSystemType object>¶
- class blivet.formats.fs.NoDevFS(*args, **kwargs)¶
Bases:
FSnodev 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.ReiserFS(*args, **kwargs)¶
Bases:
FSreiserfs 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.StratisXFS(*args, **kwargs)¶
Bases:
XFSXFS 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
FSUDF 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.
- class blivet.formats.fs.XFS(*args, **kwargs)¶
Bases:
FSXFS 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
DeviceFormatBitLocker 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
Note
The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- property status¶
Return an attribute of instance, which is of type owner.
- class blivet.formats.luks.Integrity(*args, **kwargs)¶
Bases:
DeviceFormatDM integrity format
- Parameters:
Note
The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.Note
Setting passphrase and key file kwargs is considered deprecated, the new API to set “keyslot contexts” should be used instead: see the contexts property and the crypto.KeyslotContextList class. This new API allows setting multiple passphrases and or key files for the LUKS device and will allow using more types of LUKS key slots (kernel keyring, TPM, FIDO etc.) in the future. Setting multiple contexts for a non-existing LUKS format means all the specified passphrases and key files will be used when creating the format: specifying two passphrase contexts and one key file context will mean the new LUKS format will be created with three key slots. For existing LUKS devices if you set multiple contexts, only the highest priority context (by default the first passphrase context) will be used when activating the LUKS device.
- add_key(ncontext)¶
Add a new key to an existing LUKS device.
Add the specified context (passphrase, key file…) to an available key slot in the LUKS header.
- Parameters:
ncontext (
KeyslotContextobject) – new context to add the LUKS format
Note
The LUKS format must have at least one valid context set to be able to add a new key.
- 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 contexts¶
Passphrases and key files set for this LUKS format. For non-existing LUKS formats these will be added as key slots when creating the format, for existing LUKS formats at least one context needs to be set to be able to activate the format.
- 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
- label_format_ok(label)¶
Return True if the label has an acceptable format for this format. None, which represents accepting the default for this device, is always acceptable.
- Parameters:
label (str or None) – A possible label
- labeling()¶
Returns False by default since most formats are non-labeling.
- 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.
- relabels()¶
Returns False by default since most formats are non-labeling.
- remove_key(context)¶
Remove a key from an existing LUKS device.
- Parameters:
context (
KeyslotContextobject) – existing context to be removed from the LUKS format
Note
Key slot specified by @context will be removed from this format even if it is the last active key slot!
- remove_passphrase(passphrase)¶
Remove specified passphrase from this device.
Note
Key slot associated with the provided passphrase will be removed from this format even if it is the last active key slot!
- 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.
- write_label(dry_run=False)¶
Create a label for this format.
- Raises:
LUKSError
If self.label is None, this means accept the default, so raise an LUKSError in this case.
Raises a LUKSError if the label can not be set.
blivet.formats.lvmpv module¶
- class blivet.formats.lvmpv.LVMPhysicalVolume(*args, **kwargs)¶
Bases:
DeviceFormatAn 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 extentdata_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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
DeviceFormatAn 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.
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:
DeviceFormatA 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:
DeviceFormatGeneric 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
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
DeviceFormatA 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
Note
The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()method.- property dict¶
Return an attribute of instance, which is of type owner.
- populate_ksdata(data)¶
- property status¶
Return an attribute of instance, which is of type owner.
blivet.formats.swap module¶
- class blivet.formats.swap.SwapSpace(*args, **kwargs)¶
Bases:
DeviceFormatSwap space
- Parameters:
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 thecreate()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:
ObjectIDGeneric 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:
- Raises:
ValueError
Note
The ‘device’ kwarg is required for existing formats. For non- existent formats, it is only necessary that the
deviceattribute be set before thecreate()method runs. Note that you can specify the device at the last moment by specifying it via the ‘device’ kwarg to thecreate()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:
- 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
- drop_cache()¶
Drop cached information stored for this format
- property dump¶
Whether or not this format will be dumped by dump(8).
- property formattable¶
Can we create formats of this type?
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.
- 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:
- Raises:
ValueError
Note
Any additional arguments will be passed on to the constructor for the format class. See the various
DeviceFormatsubclasses for an exhaustive list of the arguments that can be passed.
- blivet.formats.register_device_format(fmt_class)¶