Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- BlockDev.btrfs_add_device(mountpoint, device, extra)¶
- Parameters:
mountpoint (
str
) – mountpoint of the btrfs volume to add new device todevice (
str
) – a device to add to the btrfs volumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the addition (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the device was successfully added to the mountpoint btrfs volume or not
Tech category:
BlockDev.BtrfsTech.MULTI_DEV
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.btrfs_change_label(mountpoint, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of the mountpoint filesystem was successfully set to label or not
Tech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.btrfs_check(device, extra)¶
- Parameters:
device (
str
) – a device that is part of the checked btrfs volumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the check (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the filesystem was successfully checked or not
Tech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.QUERY
- Return type:
- BlockDev.btrfs_create_snapshot(source, dest, ro, extra)¶
- Parameters:
source (
str
) – path to source subvolumedest (
str
) – path to new snapshot volumero (
bool
) – whether the snapshot should be read-onlyextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the snapshot creation (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the dest snapshot of source was successfully created or not
Tech category:
BlockDev.BtrfsTech.SNAPSHOT
-BlockDev.BtrfsTechMode.CREATE
- Return type:
- BlockDev.btrfs_create_subvolume(mountpoint, name, extra)¶
- Parameters:
mountpoint (
str
) – mountpoint of the btrfs volume to create subvolume undername (
str
) – name of the subvolumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the subvolume creation (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the mountpoint/name subvolume was successfully created or not
Tech category:
BlockDev.BtrfsTech.SUBVOL
-BlockDev.BtrfsTechMode.CREATE
- Return type:
- BlockDev.btrfs_create_volume(devices, label, data_level, md_level, extra)¶
- Parameters:
devices ([
str
]) – list of devices to create btrfs volume fromdata_level (
str
orNone
) – RAID level for the data orNone
to use the defaultmd_level (
str
orNone
) – RAID level for the metadata orNone
to use the defaultextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the volume creation (right now passed to the ‘mkfs.btrfs’ utility)
- Raises:
- Returns:
whether the new btrfs volume was created from devices or not
See mkfs.btrfs(8) for details about data_level, md_level and btrfs in general.
Tech category:
BlockDev.BtrfsTech.MULTI_DEV
-BlockDev.BtrfsTechMode.CREATE
- Return type:
- BlockDev.btrfs_delete_subvolume(mountpoint, name, extra)¶
- Parameters:
mountpoint (
str
) – mountpoint of the btrfs volume to delete subvolume fromname (
str
) – name of the subvolumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the subvolume deletion (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the mountpoint/name subvolume was successfully deleted or not
Tech category:
BlockDev.BtrfsTech.SUBVOL
-BlockDev.BtrfsTechMode.DELETE
- Return type:
- BlockDev.btrfs_filesystem_info(device)¶
- Parameters:
device (
str
) – a device that is part of the queried btrfs volume- Raises:
- Returns:
information about the device's volume’s filesystem or
None
in case of errorTech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.QUERY
- Return type:
- BlockDev.btrfs_get_default_subvolume_id(mountpoint)¶
- Parameters:
mountpoint (
str
) – mountpoint of the volume to get the default subvolume ID of- Raises:
- Returns:
ID of the mountpoint volume’s default subvolume. If 0, error may be set to indicate error
Tech category:
BlockDev.BtrfsTech.SUBVOL
-BlockDev.BtrfsTechMode.QUERY
- Return type:
- BlockDev.btrfs_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.BtrfsTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.BtrfsTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.btrfs_list_devices(device)¶
- Parameters:
device (
str
) – a device that is part of the queried btrfs volume- Raises:
- Returns:
information about the devices that are part of the btrfs volume containing device or
None
in case of errorTech category:
BlockDev.BtrfsTech.MULTI_DEV
-BlockDev.BtrfsTechMode.QUERY
- Return type:
- BlockDev.btrfs_list_subvolumes(mountpoint, snapshots_only)¶
- Parameters:
- Raises:
- Returns:
information about the subvolumes that are part of the btrfs volume mounted at mountpoint or
None
in case of errorThe subvolumes are sorted in a way that no child subvolume appears in the list before its parent (sub)volume.
Tech category:
BlockDev.BtrfsTech.SUBVOL
-BlockDev.BtrfsTechMode.QUERY
- Return type:
- BlockDev.btrfs_mkfs(devices, label, data_level, md_level, extra)¶
- Parameters:
devices ([
str
]) – list of devices to create btrfs volume fromdata_level (
str
orNone
) – RAID level for the data orNone
to use the defaultmd_level (
str
orNone
) – RAID level for the metadata orNone
to use the defaultextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the volume creation (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the new btrfs volume was created from devices or not
See mkfs.btrfs(8) for details about data_level, md_level and btrfs in general.
Tech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.CREATE
- Return type:
- BlockDev.btrfs_remove_device(mountpoint, device, extra)¶
- Parameters:
mountpoint (
str
) – mountpoint of the btrfs volume to remove device fromdevice (
str
) – a device to remove from the btrfs volumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the removal (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the device was successfully removed from the mountpoint btrfs volume or not
Tech category:
BlockDev.BtrfsTech.MULTI_DEV
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.btrfs_repair(device, extra)¶
- Parameters:
device (
str
) – a device that is part of the to be repaired btrfs volumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the filesystem was successfully checked and repaired or not
Tech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.btrfs_resize(mountpoint, size, extra)¶
- Parameters:
mountpoint (
str
) – a mountpoint of the to be resized btrfs filesystemsize (
int
) – requested new sizeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the volume resize (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the mountpoint filesystem was successfully resized to size or not
Tech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.btrfs_set_default_subvolume(mountpoint, subvol_id, extra)¶
- Parameters:
mountpoint (
str
) – mountpoint of the volume to set the default subvolume ID ofsubvol_id (
int
) – ID of the subvolume to be set as the default subvolumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the setting (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the mountpoint volume’s default subvolume was correctly set to subvol_id or not
Tech category:
BlockDev.BtrfsTech.SUBVOL
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.crypto_bitlk_close(bitlk_device)¶
- Parameters:
bitlk_device (
str
) – BITLK device to close- Raises:
- Returns:
whether the given bitlk_device was successfully closed or not
Tech category:
BlockDev.CryptoTech.BITLK
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
- BlockDev.crypto_bitlk_info(device)¶
- Parameters:
device (
str
) – a device to get information about- Raises:
- Return type:
Returns (transfer full): information about the device or
None
in case of errorTech category:
BlockDev.CryptoTech.BITLK
-BlockDev.CryptoTechMode.QUERY
- BlockDev.crypto_bitlk_open(device, name, context, read_only)¶
- Parameters:
device (
str
) – the device to openname (
str
) – name for the BITLK devicecontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this BITLK deviceread_only (
bool
) – whether to open as read-only or not (meaning read-write)
- Raises:
- Returns:
whether the device was successfully opened or not
Tech category:
BlockDev.CryptoTech.BITLK
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_device_is_luks(device)¶
- Parameters:
device (
str
) – the queried device- Raises:
- Returns:
True
if the given device is a LUKS device orFalse
if not or failed to determine (the error) is populated with the error in such cases)Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.QUERY
- Return type:
- BlockDev.crypto_device_seems_encrypted(device)¶
- Parameters:
device (
str
) – the queried device- Raises:
- Returns:
True
if the given device seems to be encrypted orFalse
if not or failed to determine (the error) is populated with the error in such cases)Tech category:
BlockDev.CryptoTech.TRUECRYPT
-BlockDev.CryptoTechMode.QUERY
- Return type:
Determines whether a block device seems to be encrypted.
TCRYPT volumes are not easily identifiable, because they have no cleartext header, but are completely encrypted. This function is used to determine whether a block device is a candidate for being TCRYPT encrypted.
To achieve this, we calculate the chi square value of the first 512 Bytes and treat devices with a chi square value between 136 and 426 as candidates for being encrypted. For the reasoning, see: https://tails.boum.org/blueprint/veracrypt/
- BlockDev.crypto_escrow_device(device, passphrase, cert_data, directory, backup_passphrase)¶
- Parameters:
device (
str
) – path of the device to create escrow data forpassphrase (
str
) –BlockDev.passphrase
used for the devicecert_data ([
int
]) – certificate data to use for escrowdirectory (
str
) – directory to put escrow data intobackup_passphrase (
str
orNone
) – backupBlockDev.passphrase
for the device orNone
- Raises:
- Returns:
whether the escrow data was successfully created for device or not
Tech category:
BlockDev.CryptoTech.ESCROW
-BlockDev.CryptoTechMode.CREATE
- Return type:
- BlockDev.crypto_fvault2_close(fvault2_device)¶
- Parameters:
fvault2_device (
str
) – FVAULT2 device to close- Raises:
- Returns:
whether the given fvault2_device was successfully closed or not
Tech category:
BlockDev.CryptoTech.FVAULT2
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
- BlockDev.crypto_fvault2_open(device, name, context, read_only)¶
- Parameters:
device (
str
) – the device to openname (
str
) – name for the FVAULT2 devicecontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this FVAULT2 volumeread_only (
bool
) – whether to open as read-only or not (meaning read-write)
- Raises:
- Returns:
whether the device was successfully opened or not
Tech category:
BlockDev.CryptoTech.FVAULT2
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_generate_backup_passphrase()¶
- Raises:
- Returns:
A newly generated %BD_CRYPTO_BACKUP_PASSPHRASE_LENGTH-long
BlockDev.passphrase
.See %BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET for the definition of the charset used for the
BlockDev.passphrase
.Tech category: always available
- Return type:
- BlockDev.crypto_integrity_close(integrity_device)¶
- Parameters:
integrity_device (
str
) – integrity device to close- Raises:
- Returns:
whether the given integrity_device was successfully closed or not
Tech category:
BlockDev.CryptoTech.INTEGRITY
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
- BlockDev.crypto_integrity_format(device, algorithm, wipe, context, extra)¶
- Parameters:
device (
str
) – a device to format as integrityalgorithm (
str
) – integrity algorithm specification (e.g. “crc32c” or “sha256”)wipe (
bool
) – whether to wipe the device after format; a device that is not initially wiped will contain invalid checksumscontext (
BlockDev.CryptoKeyslotContext
orNone
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this deviceextra (
BlockDev.CryptoIntegrityExtra
orNone
) – extra arguments for integrity format creation
- Raises:
- Returns:
whether the given device was successfully formatted as integrity or not (the error) contains the error in such cases)
Tech category:
BlockDev.CryptoTech.INTEGRITY
-BlockDev.CryptoTechMode.CREATE
- Return type:
Formats the given device as integrity according to the other parameters given.
Supported context types for this function: volume key
- BlockDev.crypto_integrity_info(device)¶
- Parameters:
device (
str
) – a device to get information about- Raises:
- Returns:
information about the device or
None
in case of errorTech category:
BlockDev.CryptoTech.INTEGRITY
-BlockDev.CryptoTechMode.QUERY
- Return type:
- BlockDev.crypto_integrity_open(device, name, algorithm, context, flags, extra)¶
- Parameters:
device (
str
) – integrity device to openname (
str
) – name for the opened devicealgorithm (
str
) – integrity algorithm specification (e.g. “crc32c” or “sha256”)context (
BlockDev.CryptoKeyslotContext
orNone
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this deviceflags (
BlockDev.CryptoIntegrityOpenFlags
) – flags for the integrity device activationextra (
BlockDev.CryptoIntegrityExtra
orNone
) – extra arguments for integrity open
- Raises:
- Returns:
whether the device was successfully opened or not
Tech category:
BlockDev.CryptoTech.INTEGRITY
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
Supported context types for this function: volume key
- BlockDev.crypto_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.CryptoTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.CryptoTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.crypto_keyring_add_key(key_desc, key_data)¶
- Parameters:
- Raises:
- Returns:
whether the given key was successfully saved to kernel
BlockDev.keyring
or notTech category:
BlockDev.CryptoTech.KEYRING
-BlockDev.CryptoTechMode.ADD_KEY
- Return type:
- BlockDev.crypto_luks_add_key(device, context, ncontext)¶
- Parameters:
device (
str
) – device to add new key tocontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) to for this LUKS devicencontext (
BlockDev.CryptoKeyslotContext
) – new key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) to add to this LUKS device
- Raises:
- Returns:
whether the ncontext was successfully added to device or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.ADD_KEY
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_luks_change_key(device, context, ncontext)¶
- Parameters:
device (
str
) – device to change key ofcontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this LUKS devicencontext (
BlockDev.CryptoKeyslotContext
) – new key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) to add to this LUKS device
- Raises:
- Returns:
whether the key was successfully changed or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.ADD_KEY
&:obj:BlockDev.CryptoTechMode.REMOVE_KEY- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_luks_close(luks_device)¶
- Parameters:
luks_device (
str
) – LUKS device to close- Raises:
- Returns:
whether the given luks_device was successfully closed or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
- BlockDev.crypto_luks_format(device, cipher, key_size, context, min_entropy, luks_version, extra)¶
- Parameters:
device (
str
) – a device to format as LUKScipher (
str
orNone
) – cipher specification (type-mode, e.g. “aes-xts-plain64”) orNone
to use the defaultkey_size (
int
) – size of the volume key in bits or 0 to use the defaultcontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this LUKS devicemin_entropy (
int
) – minimum random data entropy (in bits) required to format device as LUKSluks_version (
BlockDev.CryptoLUKSVersion
) – whether to use LUKS v1 or LUKS v2extra (
BlockDev.CryptoLUKSExtra
orNone
) – extra arguments for LUKS format creation
- Raises:
- Returns:
whether the given device was successfully formatted as LUKS or not (the error) contains the error in such cases)
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.CREATE
- Return type:
Formats the given device as LUKS according to the other parameters given. If min_entropy is specified (greater than 0), the function waits for enough entropy to be available in the random data pool (WHICH MAY POTENTIALLY TAKE FOREVER).
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_luks_header_backup(device, backup_file)¶
- Parameters:
- Raises:
- Returns:
whether the given backup of device was successfully written to backup_file or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.BACKUP_RESTORE
- Return type:
- BlockDev.crypto_luks_header_restore(device, backup_file)¶
- Parameters:
- Raises:
- Returns:
whether the given device LUKS header was successfully restored from backup_file
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.BACKUP_RESTORE
- Return type:
- BlockDev.crypto_luks_info(device)¶
- Parameters:
device (
str
) – a device to get information about- Raises:
- Returns:
information about the device or
None
in case of errorTech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.QUERY
- Return type:
- BlockDev.crypto_luks_kill_slot(device, slot)¶
- Parameters:
- Raises:
- Returns:
whether the given slot was successfully destroyed or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.REMOVE_KEY
- Return type:
Note: This can destroy last remaining keyslot without confirmation making the LUKS device permanently inaccessible.
- BlockDev.crypto_luks_open(device, name, context, read_only)¶
- Parameters:
device (
str
) – the device to openname (
str
) – name for the LUKS devicecontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) to open this LUKS deviceread_only (
bool
) – whether to open as read-only or not (meaning read-write)
- Raises:
- Returns:
whether the device was successfully opened or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.OPEN_CLOSE
Example of using
BlockDev.crypto_luks_open
withBlockDev.CryptoKeyslotContext
:BDCryptoKeyslotContext *context = NULL; context = bd_crypto_keyslot_context_new_passphrase ("passphrase", 10, NULL); bd_crypto_luks_open ("/dev/vda1", "luks-device", context, FALSE, NULL);
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file,BlockDev.keyring
- BlockDev.crypto_luks_remove_key(device, context)¶
- Parameters:
device (
str
) – device to add new key tocontext (
BlockDev.CryptoKeyslotContext
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) to remove from this LUKS device
- Raises:
- Returns:
whether the key was successfully removed or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.REMOVE_KEY
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_luks_resize(luks_device, size, context)¶
- Parameters:
luks_device (
str
) – opened LUKS device to resizesize (
int
) – requested size in sectors or 0 to adapt to the backing devicecontext (
BlockDev.CryptoKeyslotContext
orNone
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for this LUKS device
- Raises:
- Returns:
whether the luks_device was successfully resized or not
You need to specify either context for LUKS 2 devices that don’t have verified key loaded in kernel. For LUKS 1 devices you can set context
None
.Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.RESIZE
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_luks_resume(luks_device, context)¶
- Parameters:
luks_device (
str
) – LUKS device to resumecontext (
BlockDev.CryptoKeyslotContext
orNone
) – key slot context (BlockDev.passphrase
/BlockDev.keyfile
/token…) for luks_device
- Raises:
- Returns:
whether the given luks_device was successfully resumed or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.SUSPEND_RESUME
- Return type:
Supported context types for this function:
BlockDev.passphrase
, key file
- BlockDev.crypto_luks_set_label(device, label, subsystem)¶
- Parameters:
- Raises:
- Returns:
whether the given label and subsystem were successfully set or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.MODIFY
- Return type:
- BlockDev.crypto_luks_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the given uuid was successfully set or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.MODIFY
- Return type:
- BlockDev.crypto_luks_status(luks_device)¶
- Parameters:
luks_device (
str
) – the queried LUKS device- Raises:
- Returns:
one of “invalid”, “inactive”, “active” or “busy” or
None
if failed to determine (error is populated with the error in such cases)Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.QUERY
- Return type:
- BlockDev.crypto_luks_suspend(luks_device)¶
- Parameters:
luks_device (
str
) – LUKS device to suspend- Raises:
- Returns:
whether the given luks_device was successfully suspended or not
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.SUSPEND_RESUME
- Return type:
- BlockDev.crypto_luks_token_info(device)¶
- Parameters:
device (
str
) – a device to get LUKS2 token information about- Raises:
- Returns:
information about tokens on device
Tech category:
BlockDev.CryptoTech.LUKS
-BlockDev.CryptoTechMode.QUERY
- Return type:
- BlockDev.crypto_tc_close(tc_device)¶
- Parameters:
tc_device (
str
) – TrueCrypt/VeraCrypt device to close- Raises:
- Returns:
whether the given tc_device was successfully closed or not
Tech category:
BlockDev.CryptoTech.TRUECRYPT
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
- BlockDev.crypto_tc_open(device, name, context, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only)¶
- Parameters:
device (
str
) – the device to openname (
str
) – name for the TrueCrypt/VeraCrypt devicecontext (
BlockDev.CryptoKeyslotContext
orNone
) –BlockDev.passphrase
key slot context for this TrueCrypt/VeraCrypt volumekeyfiles ([
str
] orNone
) – paths to the keyfiles for the TrueCrypt/VeraCrypt volumehidden (
bool
) – whether a hidden volume inside the volume should be openedsystem (
bool
) – whether to try opening as an encrypted system (with boot loader)veracrypt (
bool
) – whether to try VeraCrypt modes (TrueCrypt modes are tried anyway)veracrypt_pim (
int
) – VeraCrypt PIM value (only used if veracrypt isTrue
)read_only (
bool
) – whether to open as read-only or not (meaning read-write)
- Raises:
- Returns:
whether the device was successfully opened or not
Tech category:
BlockDev.CryptoTech.TRUECRYPT
-BlockDev.CryptoTechMode.OPEN_CLOSE
- Return type:
Supported context types for this function:
BlockDev.passphrase
- BlockDev.dm_create_linear(map_name, device, length, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the new linear mapping map_name was successfully created for the device or not
Tech category:
BlockDev.DMTech.DM_TECH_MAP
-BlockDev.DMTechMode.CREATE_ACTIVATE
- Return type:
- BlockDev.dm_get_subsystem_from_name(device_name)¶
- Parameters:
device_name (
str
) – name of the device- Raises:
- Returns:
subsystem of the given device
Tech category:
BlockDev.DMTech.DM_TECH_MAP
-BlockDev.DMTechMode.QUERY
- Return type:
- BlockDev.dm_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.DMTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.DMTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.dm_map_exists(map_name, live_only, active_only)¶
- Parameters:
- Raises:
- Returns:
whether the given map_name exists (and is live if live_only is
True
(and is active if active_only isTrue
)).Tech category:
BlockDev.DMTech.DM_TECH_MAP
-BlockDev.DMTechMode.QUERY
- Return type:
- BlockDev.dm_name_from_node(dm_node)¶
- Parameters:
dm_node (
str
) – name of the DM node (e.g. “dm-0”)- Raises:
- Returns:
map name of the map providing the dm_node device or
None
(error) contains the error in such casesTech category:
BlockDev.DMTech.DM_TECH_MAP
-BlockDev.DMTechMode.QUERY
- Return type:
- BlockDev.dm_node_from_name(map_name)¶
- Parameters:
map_name (
str
) – name of the queried DM map- Raises:
- Returns:
DM node name for the map_name map or
None
(error) contains the error in such casesTech category:
BlockDev.DMTech.DM_TECH_MAP
-BlockDev.DMTechMode.QUERY
- Return type:
- BlockDev.dm_remove(map_name)¶
- Parameters:
map_name (
str
) – name of the map to remove- Raises:
- Returns:
whether the map_name map was successfully removed or not
Tech category:
BlockDev.DMTech.DM_TECH_MAP
-BlockDev.DMTechMode.REMOVE_DEACTIVATE
- Return type:
- BlockDev.ensure_init(require_plugins, log_func)¶
- Parameters:
require_plugins ([
BlockDev.PluginSpec
] orNone
) –None
-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) orNone
to load all pluginslog_func (
BlockDev.UtilsLogFunc
orNone
) – logging function to use
- Raises:
- Returns:
whether the library was successfully initialized with all the required or default (see require_plugins) plugins or not either before or by this call
- Return type:
Checks the state of the library and if it is uninitialized or not all the require_plugins plugins are available, tries to (re)initialize it. Otherwise just returns early. The difference between:
if (!bd_is_initialized()) bd_init(None, None, &error);
and this function is that this function does the check and init in an atomic way (holding the lock preventing other threads from doing changes in between).
- BlockDev.extra_arg_list_free(args)¶
- Parameters:
args ([
BlockDev.ExtraArg
] orNone
) – A list ofBlockDev.ExtraArg
to free
Frees args and all its elements.
- BlockDev.fs_btrfs_check(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the check (right now passed to the ‘btrfsck’ utility)
- Raises:
- Returns:
whether the filesystem was successfully checked or not
Tech category:
BlockDev.FSTech.BTRFS
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_btrfs_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the Btrfs file system or not (reason is provided in error)
Note: This function is intended to be used for btrfs filesystem on a single device, for more complicated setups use the btrfs plugin instead.
Tech category: always available
- Return type:
- BlockDev.fs_btrfs_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the Btrfs file system or not (reason is provided in error)
Note: This function is intended to be used for btrfs filesystem on a single device, for more complicated setups use the btrfs plugin instead.
Tech category: always available
- Return type:
- BlockDev.fs_btrfs_get_info(mpoint)¶
- Parameters:
mpoint (
str
) – a mountpoint of the btrfs filesystem to get information about- Raises:
- Returns:
information about the file system on device or
None
in case of errorNote: This function WON’T WORK for multi device btrfs filesystems, for more complicated setups use the btrfs plugin instead.
Tech category:
BlockDev.FSTech.BTRFS
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_btrfs_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new btrfs fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkfs.btrfs’ utility)
- Raises:
- Returns:
whether a new btrfs fs was successfully created on device or not
Tech category:
BlockDev.FSTech.BTRFS
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_btrfs_repair(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the filesystem was successfully checked and repaired or not
Tech category:
BlockDev.FSTech.BTRFS
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_btrfs_resize(mpoint, new_size, extra)¶
- Parameters:
mpoint (
str
) – a mountpoint of the to be resized btrfs filesystemnew_size (
int
) – requested new sizeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the volume resize (right now passed to the ‘btrfs’ utility)
- Raises:
- Returns:
whether the mpoint filesystem was successfully resized to new_size or not
Note: This function WON’T WORK for multi device btrfs filesystems, for more complicated setups use the btrfs plugin instead.
Tech category:
BlockDev.BtrfsTech.FS
-BlockDev.BtrfsTechMode.MODIFY
- Return type:
- BlockDev.fs_btrfs_set_label(mpoint, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of Btrfs file system on the mpoint was successfully set or not
Note: This function is intended to be used for btrfs filesystem on a single device, for more complicated setups use the btrfs plugin instead.
Tech category:
BlockDev.FSTech.BTRFS
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_btrfs_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of the Btrfs file system on the device was successfully set or not
Note: This function is intended to be used for btrfs filesystem on a single device, for more complicated setups use the btrfs plugin instead.
Tech category:
BlockDev.FSTech.BTRFS
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_can_check(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed consistency check support- Raises:
- Returns:
whether filesystem check is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for checking (if missing i.e. returns
False
but no error)
- Return type:
Searches for the required utility to check the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support checking result in errors.
- BlockDev.fs_can_get_free_space(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed free space querying support- Raises:
- Returns:
whether getting filesystem free space is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for free space querying (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to get free space of the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support free space querying result in errors.
- BlockDev.fs_can_get_info(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for info querying support- Raises:
- Returns:
whether getting filesystem info is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for info querying (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to get info of the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support info querying result in errors.
- BlockDev.fs_can_get_min_size(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed minimum size querying support- Raises:
- Returns:
whether getting filesystem size is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for size querying (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to get minimum size of the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support minimum size querying result in errors.
- BlockDev.fs_can_get_size(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed size querying support- Raises:
- Returns:
whether getting filesystem size is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for size querying (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to get size of the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support size querying result in errors.
- BlockDev.fs_can_mkfs(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed mkfs support- Raises:
- Returns:
whether filesystem mkfs tool is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- options:
flags for allowed mkfs options (i.e. support for setting label or UUID when creating the filesystem)
- required_utility:
the utility binary which is required for creating (if missing returns
False
but no error)
- Return type:
(
bool
, options:BlockDev.FSMkfsOptionsFlags
, required_utility:str
)
Searches for the required utility to create the given filesystem and returns whether it is installed. The options flags indicate what additional options can be specified for type. Unknown filesystems result in errors.
- BlockDev.fs_can_repair(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed repair support- Raises:
- Returns:
whether filesystem repair is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for repairing (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to repair the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support reparing result in errors.
- BlockDev.fs_can_resize(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed resize support- Raises:
- Returns:
whether filesystem resize is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- mode:
flags for allowed resizing (i.e. growing/shrinking support for online/offline)
- required_utility:
the utility binary which is required for resizing (if missing i.e. returns
False
but no error)
- Return type:
(
bool
, mode:BlockDev.FSResizeFlags
, required_utility:str
)
Searches for the required utility to resize the given filesystem and returns whether it is installed. The mode flags indicate if growing and/or shrinking resize is available if mounted/unmounted. Unknown filesystems or filesystems which do not support resizing result in errors.
- BlockDev.fs_can_set_label(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed label support- Raises:
- Returns:
whether setting filesystem label is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for relabeling (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to set the label of the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support setting the label result in errors.
- BlockDev.fs_can_set_uuid(type)¶
- Parameters:
type (
str
) – the filesystem type to be tested for installed UUID support- Raises:
- Returns:
whether setting filesystem UUID is available
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- required_utility:
the utility binary which is required for setting UUID (if missing i.e. return
False
but no error)
- Return type:
Searches for the required utility to set the UUID of the given filesystem and returns whether it is installed. Unknown filesystems or filesystems which do not support setting the UUID result in errors.
- BlockDev.fs_check(device, fstype)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device passed the consistency check or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.CHECK
- Return type:
Check filesystem on device avoiding any modifications or repairs. This calls other fs check functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_xfs_check
for XFS). This function will return an error for unknown/unsupported filesystems.Note that depending on a corresponding filesystem type and configured features running this function on a mounted filesystem may result in false errors reported.
- BlockDev.fs_check_label(fstype, label)¶
- Parameters:
- Raises:
- Returns:
whether label is a valid label for the fstype file system or not (reason is provided in error)
Tech category: always available
- Return type:
This calls other fs check label functions from this plugin based on the provided filesystem (e.g.
BlockDev.fs_xfs_check_label
for XFS). This function will return an error for unknown/unsupported filesystems.
- BlockDev.fs_check_uuid(fstype, uuid)¶
- Parameters:
- Raises:
- Returns:
whether uuid is a valid UUID for the fstype file system or not (reason is provided in error)
Tech category: always available
- Return type:
This calls other fs check uuid functions from this plugin based on the provided filesystem (e.g.
BlockDev.fs_xfs_check_uuid
for XFS). This function will return an error for unknown/unsupported filesystems.
- BlockDev.fs_clean(device, force)¶
- Parameters:
- Raises:
- Returns:
whether device was successfully cleaned or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.WIPE
- Return type:
Clean all signatures from device. Difference between this and
BlockDev.fs_wipe
() is that this function doesn’t return error if device is already empty. This will also always remove all signatures from device, not only the first one.
- BlockDev.fs_exfat_check(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘exfatfsck’ utility)
- Raises:
- Returns:
whether the exfat file system on the device is clean or not
Tech category:
BlockDev.FSTech.EXFAT
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_exfat_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the exfat file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_exfat_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the exFAT file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_exfat_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of error Tech category:BlockDev.FSTech.EXFAT
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_exfat_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new exfat fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkexfatfs’ utility)
- Raises:
- Returns:
whether a new exfat fs was successfully created on device or not
Tech category:
BlockDev.FSTech.EXFAT
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_exfat_repair(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘exfatfsck’ utility)
- Raises:
- Returns:
whether the exfat file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.EXFAT
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_exfat_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of exfat file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXFAT
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_exfat_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the volume ID of exFAT file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXFAT
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_ext2_check(device, extra)¶
- Parameters:
device (
str
) – the device the file system on which to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the check (right now passed to the ‘e2fsck’ utility)
- Raises:
- Returns:
whether an ext2 file system on the device is clean or not
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_ext2_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the ext2 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ext2_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the ext2 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ext2_get_info(device)¶
- Parameters:
device (
str
) – the device the file system of which to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_ext2_get_min_size(device)¶
- Parameters:
device (
str
) – the device containing the file system to get min size for- Raises:
- Returns:
smallest shrunken filesystem size as reported by ntfsresize in case of error 0 is returned and error is set
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ext2_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new ext2 fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mke2fs’ utility)
- Raises:
- Returns:
whether a new ext2 fs was successfully created on device or not
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_ext2_repair(device, unsafe, extra)¶
- Parameters:
device (
str
) – the device the file system on which to repairunsafe (
bool
) – whether to do unsafe operations tooextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘e2fsck’ utility)
- Raises:
- Returns:
whether an ext2 file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_ext2_resize(device, new_size, extra)¶
- Parameters:
device (
str
) – the device the file system of which to resizenew_size (
int
) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the resize (right now passed to the ‘resize2fs’ utility)
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ext2_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of ext2 file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_ext2_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of ext2 file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXT2
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_ext3_check(device, extra)¶
- Parameters:
device (
str
) – the device the file system on which to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the check (right now passed to the ‘e2fsck’ utility)
- Raises:
- Returns:
whether an ext3 file system on the device is clean or not
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_ext3_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the ext3 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ext3_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the ext3 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ext3_get_info(device)¶
- Parameters:
device (
str
) – the device the file system of which to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_ext3_get_min_size(device)¶
- Parameters:
device (
str
) – the device containing the file system to get min size for- Raises:
- Returns:
smallest shrunken filesystem size as reported by ntfsresize in case of error 0 is returned and error is set
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ext3_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new ext3 fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mke2fs’ utility)
- Raises:
- Returns:
whether a new ext3 fs was successfully created on device or not
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_ext3_repair(device, unsafe, extra)¶
- Parameters:
device (
str
) – the device the file system on which to repairunsafe (
bool
) – whether to do unsafe operations tooextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘e2fsck’ utility)
- Raises:
- Returns:
whether an ext3 file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_ext3_resize(device, new_size, extra)¶
- Parameters:
device (
str
) – the device the file system of which to resizenew_size (
int
) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the resize (right now passed to the ‘resize2fs’ utility)
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ext3_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of ext3 file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_ext3_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of ext3 file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_ext4_check(device, extra)¶
- Parameters:
device (
str
) – the device the file system on which to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the check (right now passed to the ‘e2fsck’ utility)
- Raises:
- Returns:
whether an ext4 file system on the device is clean or not
Tech category:
BlockDev.FSTech.EXT4
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_ext4_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the ext4 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ext4_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the ext4 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ext4_get_info(device)¶
- Parameters:
device (
str
) – the device the file system of which to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_ext4_get_min_size(device)¶
- Parameters:
device (
str
) – the device containing the file system to get min size for- Raises:
- Returns:
smallest shrunken filesystem size as reported by ntfsresize in case of error 0 is returned and error is set
Tech category:
BlockDev.FSTech.EXT4
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ext4_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new ext4 fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkfs.ext4’ utility)
- Raises:
- Returns:
whether a new ext4 fs was successfully created on device or not
Tech category:
BlockDev.FSTech.EXT4
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_ext4_repair(device, unsafe, extra)¶
- Parameters:
device (
str
) – the device the file system on which to repairunsafe (
bool
) – whether to do unsafe operations tooextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘e2fsck’ utility)
- Raises:
- Returns:
whether an ext4 file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.EXT4
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_ext4_resize(device, new_size, extra)¶
- Parameters:
device (
str
) – the device the file system of which to resizenew_size (
int
) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the resize (right now passed to the ‘resize2fs’ utility)
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.EXT4
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ext4_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of ext4 file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXT3
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_ext4_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of ext4 file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.EXT4
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_f2fs_check(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘fsck.f2fs’ utility)
- Raises:
- Returns:
whether an f2fs file system on the device is clean or not
Tech category:
BlockDev.FSTech.F2FS
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_f2fs_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the f2fs file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_f2fs_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.F2FS
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_f2fs_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new f2fs fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkfs.f2fs’ utility)
- Raises:
- Returns:
whether a new f2fs fs was successfully created on device or not
Tech category:
BlockDev.FSTech.F2FS
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_f2fs_repair(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘fsck.f2fs’ utility)
- Raises:
- Returns:
whether an f2fs file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.F2FS
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_f2fs_resize(device, new_size, safe, extra)¶
- Parameters:
device (
str
) – the device containing the file system to resizenew_size (
int
) – new requested size for the file system *in file system sectors* (seeBlockDev.fs_f2fs_get_info
()) (if 0, the file system is adapted to the underlying block device)safe (
bool
) – whether to perform safe resize or not (does not resize metadata)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the resize (right now passed to the ‘resize.f2fs’ utility)
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.F2FS
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_features(fstype)¶
- Parameters:
fstype (
str
) – name of the filesystem to get features for (e.g. “ext4”)- Raises:
- Return type:
Returns (transfer-none): features supported by fstype, see
BlockDev.FSFeatures
for more information.Tech category: always available
- BlockDev.fs_freeze(mountpoint)¶
- Parameters:
mountpoint (
str
) – mountpoint of the device (filesystem) to freeze- Raises:
- Returns:
whether mountpoint was successfully freezed or not
- Return type:
Freezes filesystem mounted on mountpoint. The filesystem must support freezing.
- BlockDev.fs_get_free_space(device, fstype)¶
- Parameters:
- Raises:
- Returns:
free space of filesystem on device, 0 in case of error.
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- Return type:
Get free space for filesystem on device. This calls other fs info functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_ext4_get_info
for ext4). This function will return an error for unknown/unsupported filesystems.
- BlockDev.fs_get_fstype(device)¶
- Parameters:
device (
str
) – the device to probe- Raises:
- Returns:
type of filesystem found on device,
None
in case no signature has been detected or in case of error (error is set in this case)Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- Return type:
Get first signature on device as a string.
- BlockDev.fs_get_min_size(device, fstype)¶
- Parameters:
- Raises:
- Returns:
minimum size of filesystem on device, 0 in case of error.
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.RESIZE
- Return type:
Get minimum size for filesystem on device. This calls other fs info functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_ext4_get_min_size
for ext4). This function will return an error for unknown/unsupported filesystems.
- BlockDev.fs_get_mountpoint(device)¶
- Parameters:
device (
str
) – device to find mountpoint for- Raises:
- Returns:
mountpoint for device,
None
in case device is not mounted or in case of an error (error is set in this case)Tech category:
BlockDev.FSTech.MOUNT
(no mode, ignored)- Return type:
Get mountpoint for device. If device is mounted multiple times only one mountpoint will be returned.
- BlockDev.fs_get_size(device, fstype)¶
- Parameters:
- Raises:
- Returns:
size of filesystem on device, 0 in case of error.
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.QUERY
- Return type:
Get size for filesystem on device. This calls other fs info functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_xfs_get_info
for XFS). This function will return an error for unknown/unsupported filesystems.Note: This function will mount device for filesystems that need to be mounted to gather information (like btrfs).
- BlockDev.fs_is_mountpoint(path)¶
- Parameters:
path (
str
) – path (folder) to check- Raises:
- Returns:
whether path is a mountpoint or not
Tech category:
BlockDev.FSTech.MOUNT
(no mode, ignored)- Return type:
- BlockDev.fs_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.FSTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.FSTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.fs_mkfs(device, fstype, options, extra)¶
- Parameters:
device (
str
) – the device to create the new filesystem onfstype (
str
) – name of the filesystem to create (e.g. “ext4”)options (
BlockDev.FSMkfsOptions
) – additional options like label or UUID for the filesystemextra ([
BlockDev.ExtraArg
] orNone
) – extra mkfs options not provided in options
- Raises:
- Returns:
whether fstype was successfully created on device or not.
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.MKFS
- Return type:
This is a helper function for creating filesystems with extra options. This is the same as running a filesystem-specific function like
BlockDev.fs_ext4_mkfs
and manually specifying the extra command line options.BlockDev.FSMkfsOptions
removes the need to specify supported options for selected filesystems, make sure to check whether fstype supports these options (seeBlockDev.fs_can_mkfs
) for details.When specifying additional mkfs options using extra, it’s caller’s responsibility to make sure these options do not conflict with options specified using options. Extra options are added after the options and there are no additional checks for duplicate and/or conflicting options.
- BlockDev.fs_mount(device, mountpoint, fstype, options, extra)¶
- Parameters:
device (
str
orNone
) – device to mount, if not specified mountpoint entry from fstab will be usedmountpoint (
str
orNone
) – mountpoint for device, if not specified device entry from fstab will be usedextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the mount; currently only ‘run_as_uid’ and ‘run_as_gid’ are supported; value must be a valid non zero uid (gid), if you specify one of these, the function will run in a child process with real user
- Raises:
- Returns:
whether device (or mountpoint) was successfully mounted or not
Tech category:
BlockDev.FSTech.MOUNT
(no mode, ignored)- Return type:
- BlockDev.fs_nilfs2_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the nilfs2 file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_nilfs2_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the nilfs file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_nilfs2_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.NILFS2
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_nilfs2_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new nilfs fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkfs.nilfs2’ utility)
- Raises:
- Returns:
whether a new nilfs fs was successfully created on device or not
Tech category:
BlockDev.FSTech.NILFS2
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_nilfs2_resize(device, new_size)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.NILFS2
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_nilfs2_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of nilfs file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.NILFS2
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_nilfs2_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the uuid of nilfs file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.NILFS2
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_ntfs_check(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘ntfsfix’ utility)
- Raises:
- Returns:
whether an ntfs file system on the device is clean or not
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_ntfs_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the ntfs file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ntfs_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the ntfs file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_ntfs_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for (device must not be mounted, trying to get info for a mounted device will result in an error)- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_ntfs_get_min_size(device)¶
- Parameters:
device (
str
) – the device containing the file system to get min size for- Raises:
- Returns:
smallest shrunken filesystem size as reported by ntfsresize in case of error 0 is returned and error is set
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ntfs_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new ntfs fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkntfs’ utility)
- Raises:
- Returns:
whether a new NTFS fs was successfully created on device or not
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_ntfs_repair(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘ntfsfix’ utility)
- Raises:
- Returns:
whether an NTFS file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_ntfs_resize(device, new_size)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_ntfs_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of the NTFS file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_ntfs_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of the NTFS file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.NTFS
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_repair(device, fstype)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device was successfully repaired or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.REPAIR
- Return type:
Repair filesystem on device. This calls other fs repair functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_xfs_repair
for XFS). This function will return an error for unknown/unsupported filesystems.Most filesystem tools typically require the filesystem not to be mounted.
- BlockDev.fs_resize(device, new_size, fstype)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.RESIZE
- Return type:
Resize filesystem on device. This calls other fs resize functions from this plugin based on provides or detected filesystem (e.g.
BlockDev.fs_xfs_resize
for XFS). This function will return an error for unknown/unsupported filesystems.Note: This function will mount device for filesystems that can be resized only when mounted (like XFS or Btrfs).
- BlockDev.fs_set_label(device, label, fstype)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device was successfully relabeled or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.SET_LABEL
- Return type:
Set label for filesystem on device. This calls other fs label functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_xfs_set_label
for XFS). This function will return an error for unknown/unsupported filesystems.Note: This function will mount device for filesystems that need to be mounted to set label (like btrfs).
- BlockDev.fs_set_uuid(device, uuid, fstype)¶
- Parameters:
- Raises:
- Returns:
whether the UUID on the file system on device was successfully changed or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.SET_UUID
- Return type:
Set UUID for filesystem on device. This calls other fs UUID functions from this plugin based on detected filesystem (e.g.
BlockDev.fs_xfs_set_uuid
for XFS). This function will return an error for unknown/unsupported filesystems.
- BlockDev.fs_supported_filesystems()¶
- Raises:
- Returns:
list of filesystems supported by this plugin
Note: This returns filesystems supported by libblockdev, but not necessarily by the systems this is running on, for this information you need to run one of the
bd_fs_can_
functions.Tech category: always available
- Return type:
[
str
]
- BlockDev.fs_udf_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the UDF file system or not (reason is provided in error)
Tech category: always available
- Return type:
Note: This checks only whether label adheres the length limits for Logical Volume Identifier, not the stricter limits for Volume Identifier.
- BlockDev.fs_udf_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the UDF file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_udf_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.UDF
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_udf_mkfs(device, media_type, revision, block_size, extra)¶
- Parameters:
device (
str
) – the device to create a new UDF fs onmedia_type (
str
orNone
) – specify the media type orNone
for default (‘hd’)revision (
str
orNone
) – UDF revision to use orNone
for default (‘2.01’)block_size (
int
) – block size in bytes or 0 for auto detection (device logical block size)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkudffs’ utility)
- Raises:
- Returns:
whether a new UDF fs was successfully created on device or not
Tech category:
BlockDev.FSTech.UDF
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_udf_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of UDF file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.UDF
-BlockDev.FSTechMode.SET_LABEL
- Return type:
Note: This sets both Volume Identifier and Logical Volume Identifier. Volume Identifier is truncated to 30 or 15 characters to accommodate to the different length limits of these labels.
- BlockDev.fs_udf_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of the UDF file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.UDF
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_unfreeze(mountpoint)¶
- Parameters:
mountpoint (
str
) – mountpoint of the device (filesystem) to un-freeze- Raises:
- Returns:
whether mountpoint was successfully unfreezed or not
- Return type:
Un-freezes filesystem mounted on mountpoint. The filesystem must support freezing.
- BlockDev.fs_unmount(spec, lazy, force, extra)¶
- Parameters:
spec (
str
) – mount point or device to unmountlazy (
bool
) – enable/disable lazy unmountforce (
bool
) – enable/disable force unmountextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the unmount; currently only ‘run_as_uid’ and ‘run_as_gid’ are supported; value must be a valid non zero uid (gid), if you specify one of these, the function will run in a child process with real user
- Raises:
- Returns:
whether spec was successfully unmounted or not
Tech category:
BlockDev.FSTech.MOUNT
(no mode, ignored)- Return type:
- BlockDev.fs_vfat_check(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘fsck.vfat’ utility)
- Raises:
- Returns:
whether an vfat file system on the device is clean or not
Tech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_vfat_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the vfat file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_vfat_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the vfat file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_vfat_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_vfat_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new vfat fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkfs.vfat’ utility)
- Raises:
- Returns:
whether a new vfat fs was successfully created on device or not
Tech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.MKFS
- Return type:
Please remember that FAT labels should always be uppercase.
- BlockDev.fs_vfat_repair(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘fsck.vfat’ utility)
- Raises:
- Returns:
whether an vfat file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_vfat_resize(device, new_size)¶
- Parameters:
- Raises:
- Returns:
whether the file system on device was successfully resized or not
Tech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_vfat_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of vfat file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_vfat_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the volume ID of vfat file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.VFAT
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.fs_wipe(device, all, force)¶
- Parameters:
- Raises:
- Returns:
whether signatures were successfully wiped on device or not
Tech category:
BlockDev.FSTech.GENERIC
-BlockDev.FSTechMode.WIPE
- Return type:
- BlockDev.fs_xfs_check(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to checkextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘xfs_repair’ utility)
- Raises:
- Returns:
whether an xfs file system on the device is clean or not
Note: If the file system is mounted RW, it will always be reported as not clean!
Tech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.CHECK
- Return type:
- BlockDev.fs_xfs_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for the xfs file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_xfs_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for the xfs file system or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.fs_xfs_get_info(device)¶
- Parameters:
device (
str
) – the device containing the file system to get info for (device must be mounted, trying to get info for an unmounted device will result in an error)- Raises:
- Returns:
information about the file system on device or
None
in case of errorTech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.QUERY
- Return type:
- BlockDev.fs_xfs_mkfs(device, extra)¶
- Parameters:
device (
str
) – the device to create a new xfs fs onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mkfs.xfs’ utility)
- Raises:
- Returns:
whether a new xfs fs was successfully created on device or not
Tech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.MKFS
- Return type:
- BlockDev.fs_xfs_repair(device, extra)¶
- Parameters:
device (
str
) – the device containing the file system to repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the repair (right now passed to the ‘xfs_repair’ utility)
- Raises:
- Returns:
whether an xfs file system on the device was successfully repaired (if needed) or not (error is set in that case)
Tech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.REPAIR
- Return type:
- BlockDev.fs_xfs_resize(mpoint, new_size, extra)¶
- Parameters:
mpoint (
str
) – the mount point of the file system to resizenew_size (
int
) – new requested size for the file system *in file system blocks* (seeBlockDev.fs_xfs_get_info
()) (if 0, the file system is adapted to the underlying block device)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the resize (right now passed to the ‘xfs_growfs’ utility)
- Raises:
- Returns:
whether the file system mounted on mpoint was successfully resized or not
Tech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.RESIZE
- Return type:
- BlockDev.fs_xfs_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label of xfs file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.SET_LABEL
- Return type:
- BlockDev.fs_xfs_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID of xfs file system on the device was successfully set or not
Tech category:
BlockDev.FSTech.XFS
-BlockDev.FSTechMode.SET_UUID
- Return type:
- BlockDev.get_available_plugin_names()¶
- Returns:
an array of string names of plugins that are available
- Return type:
[
str
]
- BlockDev.get_plugin_name(plugin)¶
- Parameters:
plugin (
BlockDev.Plugin
) – the queried plugin- Returns:
name of the plugin
- Return type:
- BlockDev.get_plugin_soname(plugin)¶
- Parameters:
plugin (
BlockDev.Plugin
) – the queried plugin- Returns:
name of the shared object loaded for the plugin or
None
if none is loaded- Return type:
- BlockDev.init(require_plugins, log_func)¶
- Parameters:
require_plugins ([
BlockDev.PluginSpec
] orNone
) –None
-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) orNone
to load all pluginslog_func (
BlockDev.UtilsLogFunc
orNone
) – logging function to use
- Raises:
- Returns:
whether the library was successfully initialized with all the required or default (see require_plugins) plugins or not
Example of libblockdev initialization with ‘fs’ and ‘lvm’ plugins. Specific version of the lvm plugin is required:
GError *error = NULL; gboolean ret = FALSE; BDPluginSpec fs_plugin = {BD_PLUGIN_FS, NULL}; BDPluginSpec lvm_plugin = {BD_PLUGIN_LVM, "libbd_lvm.so.3"}; BDPluginSpec *plugins[] = {&fs_plugin, &lvm_plugin, NULL}; ret = bd_init (plugins, NULL, &error);
- Return type:
- BlockDev.is_initialized()¶
- Returns:
whether the library is initialized or not
The library is considered initialized if some of the *init*() functions was/were called and either at least one plugin is loaded or 0 plugins are loaded after an explicit call that requested 0 plugins to be loaded.
- Return type:
- BlockDev.is_plugin_available(plugin)¶
- Parameters:
plugin (
BlockDev.Plugin
) – the queried plugin- Returns:
whether the given plugin is available or not
- Return type:
- BlockDev.loop_get_loop_name(file)¶
- Parameters:
file (
str
) – path of the backing file to get loop name for- Raises:
- Returns:
name of the loop device associated with the given file
Tech category:
BlockDev.LoopTech.LOOP_TECH_LOOP
-BlockDev.LoopTechMode.QUERY
- Return type:
- BlockDev.loop_info(loop)¶
- Parameters:
loop (
str
) – name of the loop device to get information about (e.g. “loop0”)- Raises:
- Returns:
information about the loop device or
None
in case of errorTech category:
BlockDev.LoopTech.LOOP_TECH_LOOP
-BlockDev.LoopTechMode.QUERY
- Return type:
- BlockDev.loop_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.LoopTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.LoopTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.loop_set_autoclear(loop, autoclear)¶
- Parameters:
- Raises:
- Returns:
whether the autoclear flag was successfully set on the loop device or not
Tech category:
BlockDev.LoopTech.LOOP_TECH_LOOP
-BlockDev.LoopTechMode.MODIFY
- Return type:
- BlockDev.loop_setup(file, offset, size, read_only, part_scan, sector_size)¶
- Parameters:
file (
str
) – file to setup as a loop deviceoffset (
int
) – offset of the start of the device (in file)size (
int
) – maximum size of the device (or 0 to leave unspecified)read_only (
bool
) – whether to setup as read-only (True
) or read-write (False
)part_scan (
bool
) – whether to enforce partition scan on the newly created device or notsector_size (
int
) – logical sector size for the loop device in bytes (or 0 for default)
- Raises:
- Returns:
whether the file was successfully setup as a loop device or not
Tech category:
BlockDev.LoopTech.LOOP_TECH_LOOP
-BlockDev.LoopTechMode.CREATE
- loop_name:
if not
None
, it is used to store the name of the loop device
- Return type:
- BlockDev.loop_setup_from_fd(fd, offset, size, read_only, part_scan, sector_size)¶
- Parameters:
fd (
int
) – file descriptor for a file to setup as a new loop deviceoffset (
int
) – offset of the start of the device (in file given by fd)size (
int
) – maximum size of the device (or 0 to leave unspecified)read_only (
bool
) – whether to setup as read-only (True
) or read-write (False
)part_scan (
bool
) – whether to enforce partition scan on the newly created device or notsector_size (
int
) – logical sector size for the loop device in bytes (or 0 for default)
- Raises:
- Returns:
whether an new loop device was successfully setup for fd or not
Tech category:
BlockDev.LoopTech.LOOP_TECH_LOOP
-BlockDev.LoopTechMode.CREATE
- loop_name:
if not
None
, it is used to store the name of the loop device
- Return type:
- BlockDev.loop_teardown(loop)¶
- Parameters:
loop (
str
) – path or name of the loop device to tear down- Raises:
- Returns:
whether the loop device was successfully torn down or not
Tech category:
BlockDev.LoopTech.LOOP_TECH_LOOP
-BlockDev.LoopTechMode.DESTROY
- Return type:
- BlockDev.lvm_add_lv_tags(vg_name, lv_name, tags)¶
- Parameters:
- Raises:
- Returns:
whether the tags were successfully added to device or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_add_pv_tags(device, tags)¶
- Parameters:
- Raises:
- Returns:
whether the tags were successfully added to device or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_add_vg_tags(vg_name, tags)¶
- Parameters:
- Raises:
- Returns:
whether the tags were successfully added to vg_name or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_cache_attach(vg_name, data_lv, cache_pool_lv, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the data_lv and the cache_pool_lv LVsdata_lv (
str
) – data LV to attach the cache_pool_lv tocache_pool_lv (
str
) – cache pool LV to attach to the data_lvextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the cache attachment (just passed to LVM as is)
- Raises:
- Returns:
whether the cache_pool_lv was successfully attached to the data_lv or not
Note: Both data_lv and cache_lv will be deactivated before the operation.
Tech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_cache_create_cached_lv(vg_name, lv_name, data_size, cache_size, md_size, mode, flags, slow_pvs, fast_pvs)¶
- Parameters:
vg_name (
str
) – name of the VG to create a cached LV inlv_name (
str
) – name of the cached LV to createdata_size (
int
) – size of the data LVcache_size (
int
) – size of the cache (or cached LV more precisely)md_size (
int
) – size of the cache metadata LV or 0 to use the defaultmode (
BlockDev.LVMCacheMode
) – cache mode for the cached LVflags (
BlockDev.LVMCachePoolFlags
) – a combination of (ORed)BlockDev.LVMCachePoolFlags
slow_pvs ([
str
]) – list of slow PVs (used for the data LV)fast_pvs ([
str
]) – list of fast PVs (used for the cache LV)
- Raises:
- Returns:
whether the cached LV lv_name was successfully created or not
Tech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_cache_create_pool(vg_name, pool_name, pool_size, md_size, mode, flags, fast_pvs)¶
- Parameters:
vg_name (
str
) – name of the VG to create pool_name inpool_name (
str
) – name of the cache pool LV to createpool_size (
int
) – desired size of the cache pool pool_namemd_size (
int
) – desired size of the pool_name cache pool’s metadata LV or 0 to use the defaultmode (
BlockDev.LVMCacheMode
) – cache mode of the pool_name cache poolflags (
BlockDev.LVMCachePoolFlags
) – a combination of (ORed)BlockDev.LVMCachePoolFlags
fast_pvs ([
str
]) – list of (fast) PVs to create the pool_name cache pool (and the metadata LV)
- Raises:
- Returns:
whether the cache pool vg_name/pool_name was successfully created or not
Tech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_cache_detach(vg_name, cached_lv, destroy, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the cached_lvcached_lv (
str
) – name of the cached LV to detach its cache fromdestroy (
bool
) – whether to destroy the cache after detach or notextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the cache detachment (just passed to LVM as is)
- Raises:
- Returns:
whether the cache was successfully detached from the cached_lv or not
Note: synces the cache first
Tech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_cache_get_default_md_size(cache_size)¶
- Parameters:
cache_size (
int
) – size of the cache to determine MD size for- Raises:
- Returns:
recommended default size of the cache metadata LV or 0 in case of error
Tech category:
BlockDev.LVMTech.CACHE_CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_cache_get_mode_from_str(mode_str)¶
- Parameters:
mode_str (
str
) – string representation of a cache mode- Raises:
- Returns:
cache mode for the mode_str or
BlockDev.LVMCacheMode.UNKNOWN
if failed to determineTech category: always provided/supported
- Return type:
- BlockDev.lvm_cache_get_mode_str(mode)¶
- Parameters:
mode (
BlockDev.LVMCacheMode
) – mode to get the string representation for- Raises:
- Returns:
string representation of mode or
None
in case of errorTech category: always provided/supported
- Return type:
- BlockDev.lvm_cache_pool_convert(vg_name, data_lv, metadata_lv, name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG to create the new thin pool indata_lv (
str
) – name of the LV that should become the data part of the new poolmetadata_lv (
str
) – name of the LV that should become the metadata part of the new poolname (
str
orNone
) – name for the thin pool (ifNone
, the name data_lv is inherited)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the thin pool creation (just passed to LVM as is)
- Raises:
- Returns:
whether the new cache pool was successfully created from data_lv and metadata_lv or not
Tech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.CREATE
- Return type:
Converts the data_lv and metadata_lv into a new cache pool in the vg_name VG.
- BlockDev.lvm_cache_pool_name(vg_name, cached_lv)¶
- Parameters:
- Raises:
- Returns:
name of the cache pool LV used by the cached_lv or
None
in case of errorTech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_cache_stats(vg_name, cached_lv)¶
- Parameters:
- Raises:
- Returns:
stats for the cached_lv or
None
in case of errorTech category:
BlockDev.LVMTech.CACHE
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_delete_lv_tags(vg_name, lv_name, tags)¶
- Parameters:
- Raises:
- Returns:
whether the tags were successfully removed from device or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_delete_pv_tags(device, tags)¶
- Parameters:
- Raises:
- Returns:
whether the tags were successfully removed from device or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_delete_vg_tags(vg_name, tags)¶
- Parameters:
- Raises:
- Returns:
whether the tags were successfully removed from vg_name or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_devices_add(device, devices_file, extra)¶
- Parameters:
- Raises:
- Returns:
whether the device was successfully added to devices_file or not
Tech category:
BlockDev.LVMTech.DEVICES
no mode (it is ignored)- Return type:
- BlockDev.lvm_devices_delete(device, devices_file, extra)¶
- Parameters:
- Raises:
- Returns:
whether the device was successfully removed from devices_file or not
Tech category:
BlockDev.LVMTech.DEVICES
no mode (it is ignored)- Return type:
- BlockDev.lvm_get_devices_filter()¶
- Raises:
- Returns:
a copy of a string representation of the currently set LVM devices filter
Tech category:
BlockDev.LVMTech.DEVICES
no mode (it is ignored)- Return type:
[
str
]
- BlockDev.lvm_get_global_config()¶
- Raises:
- Returns:
a copy of a string representation of the currently set LVM global configuration
Tech category:
BlockDev.LVMTech.GLOB_CONF
no mode (it is ignored)- Return type:
- BlockDev.lvm_get_lv_physical_size(lv_size, pe_size)¶
- Parameters:
- Raises:
- Returns:
space taken on disk(s) by the LV with given size
Gives number of bytes needed for an LV with the size lv_size on an LVM stack using given pe_size.
Tech category:
BlockDev.LVMTech.CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_get_max_lv_size()¶
- Raises:
- Returns:
maximum LV size in bytes
Tech category:
BlockDev.LVMTech.CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_get_supported_pe_sizes()¶
- Raises:
- Returns:
list of supported PE sizes
Tech category:
BlockDev.LVMTech.CALCS
no mode (it is ignored)- Return type:
[
int
]
- BlockDev.lvm_get_thpool_meta_size(size, chunk_size, n_snapshots)¶
- Parameters:
- Raises:
- Returns:
recommended size of the metadata space for the specified pool
Tech category:
BlockDev.LVMTech.THIN_CALCS
no mode (it is ignored)- Return type:
Note: This function will be changed in 3.0: the n_snapshots parameter is currently not used and will be removed.
- BlockDev.lvm_get_thpool_padding(size, pe_size, included)¶
- Parameters:
- Raises:
- Returns:
size of the padding needed for a thin pool with the given size according to the pe_size and included
Tech category:
BlockDev.LVMTech.THIN_CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_get_vdo_compression_state_str(state)¶
- Parameters:
state (
BlockDev.LVMVDOCompressionState
) – state to get the string representation for- Raises:
- Returns:
string representation of state or
None
in case of errorTech category: always provided/supported
- Return type:
- BlockDev.lvm_get_vdo_index_state_str(state)¶
- Parameters:
state (
BlockDev.LVMVDOIndexState
) – state to get the string representation for- Raises:
- Returns:
string representation of state or
None
in case of errorTech category: always provided/supported
- Return type:
- BlockDev.lvm_get_vdo_operating_mode_str(mode)¶
- Parameters:
mode (
BlockDev.LVMVDOOperatingMode
) – mode to get the string representation for- Raises:
- Returns:
string representation of mode or
None
in case of errorTech category: always provided/supported
- Return type:
- BlockDev.lvm_get_vdo_write_policy_from_str(policy_str)¶
- Parameters:
policy_str (
str
) – string representation of a policy- Raises:
- Returns:
write policy for the policy_str or
BlockDev.LVMVDOWritePolicy.UNKNOWN
if failed to determineTech category: always provided/supported
- Return type:
- BlockDev.lvm_get_vdo_write_policy_str(policy)¶
- Parameters:
policy (
BlockDev.LVMVDOWritePolicy
) – policy to get the string representation for- Raises:
- Returns:
string representation of policy or
None
in case of errorTech category: always provided/supported
- Return type:
- BlockDev.lvm_is_supported_pe_size(size)¶
- Parameters:
size (
int
) – size (in bytes) to test- Raises:
- Returns:
whether the given size is supported physical extent size or not
Tech category:
BlockDev.LVMTech.CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.LVMTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.LVMTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.lvm_is_valid_thpool_chunk_size(size, discard)¶
- Parameters:
- Raises:
- Returns:
whether the given size is a valid thin pool chunk size or not
Tech category:
BlockDev.LVMTech.THIN_CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_is_valid_thpool_md_size(size)¶
- Parameters:
size (
int
) – the size to be tested- Raises:
- Returns:
whether the given size is a valid thin pool metadata size or not
Tech category:
BlockDev.LVMTech.THIN_CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_lvactivate(vg_name, lv_name, ignore_skip, shared, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-activated LVlv_name (
str
) – name of the to-be-activated LVignore_skip (
bool
) – whether to ignore the skip flag or notshared (
bool
) – whether to activate the LV in shared mode (used for shared LVM setups with lvmlockd, useFalse
if not sure)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV activation (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name LV was successfully activated or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_lvcreate(vg_name, lv_name, size, type, pv_list, extra)¶
- Parameters:
vg_name (
str
) – name of the VG to create a new LV inlv_name (
str
) – name of the to-be-created LVsize (
int
) – requested size of the new LVtype (
str
orNone
) – type of the new LV (“striped”, “raid1”,…, see lvcreate (8))pv_list ([
str
] orNone
) – list of PVs the newly created LV should use orNone
if not specifiedextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV creation (just passed to LVM as is)
- Raises:
- Returns:
whether the given vg_name/lv_name LV was successfully created or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_lvdeactivate(vg_name, lv_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-deactivated LVlv_name (
str
) – name of the to-be-deactivated LVextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV deactivation (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name LV was successfully deactivated or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_lvinfo(vg_name, lv_name)¶
- Parameters:
- Raises:
- Returns:
information about the vg_name/lv_name LV or
None
in case of error (the error) gets populated in those cases)Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_lvinfo_tree(vg_name, lv_name)¶
- Parameters:
- Raises:
- Returns:
information about the vg_name/lv_name LV or
None
in case of error (the error) gets populated in those cases)Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
This function will fill out the data_lvs, metadata_lvs, and segs fields as well.
- BlockDev.lvm_lvorigin(vg_name, lv_name)¶
- Parameters:
- Raises:
- Returns:
the origin volume for the vg_name/lv_name LV or
None
if failed to determine (error) is set in those cases)Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_lvremove(vg_name, lv_name, force, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-removed LVlv_name (
str
) – name of the to-be-removed LVforce (
bool
) – whether to force removal or notextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV removal (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name LV was successfully removed or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.REMOVE
- Return type:
- BlockDev.lvm_lvrename(vg_name, lv_name, new_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-renamed LVlv_name (
str
) – name of the to-be-renamed LVnew_name (
str
) – new name for the vg_name/lv_name LVextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV rename (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name LV was successfully renamed to vg_name/new_name or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_lvrepair(vg_name, lv_name, pv_list, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-repaired LVlv_name (
str
) – name of the to-be-repaired LVpv_list ([
str
]) – list of PVs to be used for the repairextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV repair (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name LV was successfully repaired or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_lvresize(vg_name, lv_name, size, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-resized LVlv_name (
str
) – name of the to-be-resized LVsize (
int
) – the requested new size of the LVextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV resize (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name LV was successfully resized or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_lvs(vg_name)¶
- Parameters:
vg_name (
str
orNone
) – name of the VG to get information about LVs from- Raises:
- Returns:
information about LVs found in the given vg_name VG or in system if vg_name is
None
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_lvs_tree(vg_name)¶
- Parameters:
vg_name (
str
orNone
) – name of the VG to get information about LVs from- Raises:
- Returns:
information about LVs found in the given vg_name VG or in system if vg_name is
None
.Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
This function will fill out the data_lvs, metadata_lvs, and segs fields as well.
- BlockDev.lvm_lvsnapshotcreate(vg_name, origin_name, snapshot_name, size, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the LV a new snapshot should be created oforigin_name (
str
) – name of the LV a new snapshot should be created ofsnapshot_name (
str
) – name of the to-be-created snapshotsize (
int
) – requested size for the snapshotextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV snapshot creation (just passed to LVM as is)
- Raises:
- Returns:
whether the snapshot_name snapshot of the vg_name/origin_name LV was successfully created or not.
Tech category:
BlockDev.LVMTech.BASIC_SNAP
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_lvsnapshotmerge(vg_name, snapshot_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-merged LV snapshotsnapshot_name (
str
) – name of the to-be-merged LV snapshotextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the LV snapshot merge (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/snapshot_name LV snapshot was successfully merged or not
Tech category:
BlockDev.LVMTech.BASIC_SNAP
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_pvcreate(device, data_alignment, metadata_size, extra)¶
- Parameters:
device (
str
) – the device to make PV fromdata_alignment (
int
) – data (first PE) alignment or 0 to use the defaultmetadata_size (
int
) – size of the area reserved for metadata or 0 to use the defaultextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the PV creation (just passed to LVM as is)
- Raises:
- Returns:
whether the PV was successfully created or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_pvinfo(device)¶
- Parameters:
- Raises:
- Returns:
information about the PV on the given device or
None
in case of error (the error) gets populated in those cases)Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_pvmove(src, dest, extra)¶
- Parameters:
- Raises:
- Returns:
whether the extents from the src PV where successfully moved or not
If dest is
None
, VG allocation rules are used for the extents from the src PV (see pvmove(8)).Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_pvremove(device, extra)¶
- Parameters:
device (
str
) – the PV device to be removed/destroyedextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the PV removal (just passed to LVM as is)
- Raises:
- Returns:
whether the PV was successfully removed/destroyed or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.REMOVE
- Return type:
- BlockDev.lvm_pvresize(device, size, extra)¶
- Parameters:
device (
str
) – the device to resizesize (
int
) – the new requested size of the PV or 0 if it should be adjusted to device’s sizeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the PV resize (just passed to LVM as is)
- Raises:
- Returns:
whether the PV’s size was successfully changed or not
If given size different from 0, sets the PV’s size to the given value (see pvresize(8)). If given size 0, adjusts the PV’s size to the underlying block device’s size.
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_pvs()¶
- Raises:
- Returns:
information about PVs found in the system
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_pvscan(device, update_cache, extra)¶
- Parameters:
- Raises:
- Returns:
whether the system or device was successfully scanned for PVs or not
The device argument is used only if update_cache is
True
. Otherwise the whole system is scanned for PVs.Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_round_size_to_pe(size, pe_size, roundup)¶
- Parameters:
- Raises:
- Returns:
size rounded to pe_size according to the roundup
Rounds given size up/down to a multiple of pe_size according to the value of the roundup parameter. If the rounded value is too big to fit in the return type, the result is rounded down (floored) regardless of the roundup parameter.
Tech category:
BlockDev.LVMTech.CALCS
no mode (it is ignored)- Return type:
- BlockDev.lvm_set_devices_filter(devices)¶
- Parameters:
devices ([
str
] orNone
) – list of devices for lvm commands to work on- Raises:
- Returns:
whether the devices filter was successfully set or not
Tech category:
BlockDev.LVMTech.DEVICES
no mode (it is ignored)- Return type:
- BlockDev.lvm_set_global_config(new_config)¶
- Parameters:
new_config (
str
orNone
) – string representation of the new global LVM configuration to set orNone
to reset to default- Raises:
- Returns:
whether the new requested global config new_config was successfully set or not
Tech category:
BlockDev.LVMTech.GLOB_CONF
no mode (it is ignored)- Return type:
- BlockDev.lvm_thlvcreate(vg_name, pool_name, lv_name, size, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the thin pool providing extents for the to-be-created thin LVpool_name (
str
) – name of the pool LV providing extents for the to-be-created thin LVlv_name (
str
) – name of the to-be-created thin LVsize (
int
) – requested virtual size of the to-be-created thin LVextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the thin LV creation (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name thin LV was successfully created or not
Tech category:
BlockDev.LVMTech.THIN
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_thlvpoolname(vg_name, lv_name)¶
- Parameters:
- Raises:
- Returns:
the name of the pool volume for the vg_name/lv_name thin LV or
None
if failed to determine (error) is set in those cases)Tech category:
BlockDev.LVMTech.THIN
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_thpool_convert(vg_name, data_lv, metadata_lv, name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG to create the new thin pool indata_lv (
str
) – name of the LV that should become the data part of the new poolmetadata_lv (
str
) – name of the LV that should become the metadata part of the new poolname (
str
orNone
) – name for the thin pool (ifNone
, the name data_lv is inherited)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the thin pool creation (just passed to LVM as is)
- Raises:
- Returns:
whether the new thin pool was successfully created from data_lv and metadata_lv or not
Tech category:
BlockDev.LVMTech.THIN
-BlockDev.LVMTechMode.CREATE
- Return type:
Converts the data_lv and metadata_lv into a new thin pool in the vg_name VG.
- BlockDev.lvm_thpoolcreate(vg_name, lv_name, size, md_size, chunk_size, profile, extra)¶
- Parameters:
vg_name (
str
) – name of the VG to create a thin pool inlv_name (
str
) – name of the to-be-created pool LVsize (
int
) – requested size of the to-be-created poolmd_size (
int
) – requested metadata size or 0 to use the defaultchunk_size (
int
) – requested chunk size or 0 to use the defaultprofile (
str
orNone
) – profile to use (see lvm(8) for more information) orNone
to use the defaultextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the thin pool creation (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name thin pool was successfully created or not
Tech category:
BlockDev.LVMTech.THIN
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_thsnapshotcreate(vg_name, origin_name, snapshot_name, pool_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the thin LV a new snapshot should be created oforigin_name (
str
) – name of the thin LV a new snapshot should be created ofsnapshot_name (
str
) – name of the to-be-created snapshotpool_name (
str
orNone
) – name of the thin pool to create the snapshot in orNone
if not specifiedextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the thin LV snapshot creation (just passed to LVM as is)
- Raises:
- Returns:
whether the snapshot_name snapshot of the vg_name/origin_name thin LV was successfully created or not.
Tech category:
BlockDev.LVMTech.THIN
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_vdo_disable_compression(vg_name, pool_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-changed VDO pool LVpool_name (
str
) – name of the VDO pool LV to disable compression onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO change (just passed to LVM as is)
- Raises:
- Returns:
whether compression was successfully disabled on vg_name/pool_name LV or not
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vdo_disable_deduplication(vg_name, pool_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-changed VDO pool LVpool_name (
str
) – name of the VDO pool LV to disable deduplication onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO change (just passed to LVM as is)
- Raises:
- Returns:
whether deduplication was successfully disabled on vg_name/pool_name LV or not
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vdo_enable_compression(vg_name, pool_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-changed VDO pool LVpool_name (
str
) – name of the VDO pool LV to enable compression onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO change (just passed to LVM as is)
- Raises:
- Returns:
whether compression was successfully enabled on vg_name/pool_name LV or not
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vdo_enable_deduplication(vg_name, pool_name, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-changed VDO pool LVpool_name (
str
) – name of the VDO pool LV to enable deduplication onextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO change (just passed to LVM as is)
- Raises:
- Returns:
whether deduplication was successfully enabled on vg_name/pool_name LV or not
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vdo_get_stats(vg_name, pool_name)¶
- Parameters:
- Raises:
- Returns:
a structure containing selected statistics or
None
in case of error (error gets populated in those cases)In contrast to bd_lvm_vdo_get_stats_full this function will only return selected statistics in a fixed structure. In case a value is not available, -1 would be returned.
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_vdo_get_stats_full(vg_name, pool_name)¶
- Parameters:
- Raises:
- Returns:
hashtable of type string - string of available statistics or
None
in case of error (error gets populated in those cases)Statistics are collected from the values exposed by the kernel
kvdo
module at the/sys/kvdo/<VDO_NAME>/statistics/
path. Some of the keys are computed to mimic the information produced by the vdo tools. Please note the contents of the hashtable may vary depending on the actual kvdo module version.Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_vdo_info(vg_name, lv_name)¶
- Parameters:
- Raises:
- Returns:
information about the vg_name/lv_name LV or
None
in case of error (the error) gets populated in those cases)Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_vdo_pool_convert(vg_name, pool_lv, name, virtual_size, index_memory, compression, deduplication, write_policy, extra)¶
- Parameters:
vg_name (
str
) – name of the VG that contains pool_lvpool_lv (
str
) – name of the LV that should become the new VDO pool LVname (
str
orNone
) – name for the VDO LV orNone
for default namevirtual_size (
int
) – virtual size for the new VDO LVindex_memory (
int
) – amount of index memory (in bytes) or 0 for defaultcompression (
bool
) – whether to enable compression or notdeduplication (
bool
) – whether to enable deduplication or notwrite_policy (
BlockDev.LVMVDOWritePolicy
) – write policy for the volumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO pool creation (just passed to LVM as is)
- Raises:
- Returns:
whether the new VDO pool LV was successfully created from pool_lv and or not
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.CREATE
&:obj:BlockDev.LVMTechMode.MODIFY- Return type:
Converts the pool_lv into a new VDO pool LV in the vg_name VG and creates a new name VDO LV with size virtual_size.
Note: All data on pool_lv will be irreversibly destroyed.
- BlockDev.lvm_vdo_pool_create(vg_name, lv_name, pool_name, data_size, virtual_size, index_memory, compression, deduplication, write_policy, extra)¶
- Parameters:
vg_name (
str
) – name of the VG to create a new LV inlv_name (
str
) – name of the to-be-created VDO LVpool_name (
str
orNone
) – name of the to-be-created VDO pool LV orNone
for default namedata_size (
int
) – requested size of the data VDO LV (physical size of the pool_name VDO pool LV)virtual_size (
int
) – requested virtual_size of the lv_name VDO LVindex_memory (
int
) – amount of index memory (in bytes) or 0 for defaultcompression (
bool
) – whether to enable compression or notdeduplication (
bool
) – whether to enable deduplication or notwrite_policy (
BlockDev.LVMVDOWritePolicy
) – write policy for the volumeextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO LV creation (just passed to LVM as is)
- Raises:
- Returns:
whether the given vg_name/lv_name VDO LV was successfully created or not
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_vdo_pool_resize(vg_name, pool_name, size, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-resized VDO pool LVpool_name (
str
) – name of the to-be-resized VDO pool LVsize (
int
) – the requested new size of the VDO pool LVextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO pool LV resize (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/pool_name VDO pool LV was successfully resized or not
Note: Size of the VDO pool LV can be only extended, not reduced.
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vdo_resize(vg_name, lv_name, size, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the to-be-resized VDO LVlv_name (
str
) – name of the to-be-resized VDO LVsize (
int
) – the requested new size of the VDO LVextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VDO LV resize (just passed to LVM as is)
- Raises:
- Returns:
whether the vg_name/lv_name VDO LV was successfully resized or not
Note: Reduction needs to process TRIM for reduced disk area to unmap used data blocks from the VDO pool LV and it may take a long time.
Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vdolvpoolname(vg_name, lv_name)¶
- Parameters:
- Raises:
- Returns:
the name of the pool volume for the vg_name/lv_name VDO LV or
None
if failed to determine (error) is set in those cases)Tech category:
BlockDev.LVMTech.VDO
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_vgactivate(vg_name, extra)¶
- Parameters:
vg_name (
str
) – name of the to be activated VGextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VG activation (just passed to LVM as is)
- Raises:
- Returns:
whether the VG was successfully activated or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vgcreate(name, pv_list, pe_size, extra)¶
- Parameters:
name (
str
) – name of the newly created VGpv_list ([
str
]) – list of PVs the newly created VG should usepe_size (
int
) – PE size or 0 if the default value should be usedextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VG creation (just passed to LVM as is)
- Raises:
- Returns:
whether the VG name was successfully created or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_vgdeactivate(vg_name, extra)¶
- Parameters:
vg_name (
str
) – name of the to be deactivated VGextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VG deactivation (just passed to LVM as is)
- Raises:
- Returns:
whether the VG was successfully deactivated or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vgextend(vg_name, device, extra)¶
- Parameters:
vg_name (
str
) – name of the to be extended VGdevice (
str
) – PV device to extend the vg_name VG withextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VG extension (just passed to LVM as is)
- Raises:
- Returns:
whether the VG vg_name was successfully extended with the given device or not.
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vginfo(vg_name)¶
- Parameters:
vg_name (
str
) – a VG to get information about- Raises:
- Returns:
information about the vg_name VG or
None
in case of error (the error) gets populated in those cases)Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_vglock_start(vg_name, extra)¶
- Parameters:
vg_name (
str
) – a shared VG to start the lockspace in lvmlockdextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the vgchange command (just passed to LVM as is)
- Raises:
- Returns:
whether the lock was successfully started for vg_name or not
Tech category:
BlockDev.LVMTech.SHARED
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vglock_stop(vg_name, extra)¶
- Parameters:
vg_name (
str
) – a shared VG to stop the lockspace in lvmlockdextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the vgchange command (just passed to LVM as is)
- Raises:
- Returns:
whether the lock was successfully stopped for vg_name or not
Tech category:
BlockDev.LVMTech.SHARED
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vgreduce(vg_name, device, extra)¶
- Parameters:
- Raises:
- Returns:
whether the VG vg_name was successfully reduced of the given device or not
Note: This function does not move extents off of the PV before removing it from the VG. You must do that first by calling
BlockDev.lvm_pvmove
.Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vgremove(vg_name, extra)¶
- Parameters:
vg_name (
str
) – name of the to be removed VGextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VG removal (just passed to LVM as is)
- Raises:
- Returns:
whether the VG was successfully removed or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.REMOVE
- Return type:
- BlockDev.lvm_vgrename(old_vg_name, new_vg_name, extra)¶
- Parameters:
old_vg_name (
str
) – old name of the VG to renamenew_vg_name (
str
) – new name for the old_vg_name VGextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the VG rename (just passed to LVM as is)
- Raises:
- Returns:
whether the VG was successfully renamed or not
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_vgs()¶
- Raises:
- Returns:
information about VGs found in the system
Tech category:
BlockDev.LVMTech.BASIC
-BlockDev.LVMTechMode.QUERY
- Return type:
- BlockDev.lvm_writecache_attach(vg_name, data_lv, cache_lv, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the data_lv and the cache_pool_lv LVsdata_lv (
str
) – data LV to attach the cache_lv tocache_lv (
str
) – cache (fast) LV to attach to the data_lvextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the cache attachment (just passed to LVM as is)
- Raises:
- Returns:
whether the cache_lv was successfully attached to the data_lv or not
Tech category:
BlockDev.LVMTech.WRITECACHE
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.lvm_writecache_create_cached_lv(vg_name, lv_name, data_size, cache_size, slow_pvs, fast_pvs)¶
- Parameters:
vg_name (
str
) – name of the VG to create a cached LV inlv_name (
str
) – name of the cached LV to createdata_size (
int
) – size of the data LVcache_size (
int
) – size of the cache (or cached LV more precisely)slow_pvs ([
str
]) – list of slow PVs (used for the data LV)fast_pvs ([
str
]) – list of fast PVs (used for the cache LV)
- Raises:
- Returns:
whether the cached LV lv_name was successfully created or not
Tech category:
BlockDev.LVMTech.WRITECACHE
-BlockDev.LVMTechMode.CREATE
- Return type:
- BlockDev.lvm_writecache_detach(vg_name, cached_lv, destroy, extra)¶
- Parameters:
vg_name (
str
) – name of the VG containing the cached_lvcached_lv (
str
) – name of the cached LV to detach its cache fromdestroy (
bool
) – whether to destroy the cache after detach or notextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the cache detachment (just passed to LVM as is)
- Raises:
- Returns:
whether the cache was successfully detached from the cached_lv or not
Note: synces the cache first
Tech category:
BlockDev.LVMTech.WRITECACHE
-BlockDev.LVMTechMode.MODIFY
- Return type:
- BlockDev.md_activate(raid_spec, members, uuid, start_degraded, extra)¶
- Parameters:
raid_spec (
str
orNone
) – specification of the RAID device (name, node or path) to activate (if not given “–scan” is implied and members is ignored)members ([
str
] orNone
) – member devices to be considered for device activationuuid (
str
orNone
) – UUID (in the MD RAID format!) of the MD RAID to activatestart_degraded (
bool
) – whether to start the array even if it’s degradedextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the activation (right now passed to the ‘mdadm’ utility)
- Raises:
- Returns:
whether the MD RAID device was successfully activated or not
Note: either members or uuid (or both) have to be specified.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_add(raid_spec, device, raid_devs, extra)¶
- Parameters:
raid_spec (
str
) – specification of the RAID device (name, node or path) to add device intodevice (
str
) – name of the device to add to the raid_spec RAID deviceraid_devs (
int
) – number of devices the raid_spec RAID should actively use or 0 to leave unspecified (see below)extra ([
BlockDev.ExtraArg
] orNone
) – extra options for the addition (right now passed to the ‘mdadm’ utility)
- Raises:
- Returns:
whether the device was successfully added to the raid_spec RAID or not
The raid_devs parameter is used when adding devices to a raid array that has no actual redundancy. In this case it is necessary to explicitly grow the array all at once rather than manage it in the sense of adding spares.
Whether the new device will be added as a spare or an active member is decided by mdadm.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_canonicalize_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to canonicalize- Raises:
- Returns:
canonicalized form of uuid
This function expects a UUID in the form that mdadm returns. The change is as follows: 3386ff85:f5012621:4a435f06:1eb47236 -> 3386ff85-f501-2621-4a43-5f061eb47236
Tech category: always available
- Return type:
- BlockDev.md_create(device_name, level, disks, spares, version, bitmap, chunk_size, extra)¶
- Parameters:
device_name (
str
) – name of the device to createlevel (
str
) – RAID level (as understood by mdadm, see mdadm(8))disks ([
str
]) – disks to use for the new RAID (including spares)spares (
int
) – number of spare devicesbitmap (
str
orNone
) – write-intent bitmap location (‘none’, ‘internal’) orNone
to let mdadm decide (i.e. internal > 100GB)chunk_size (
int
) – chunk size of the device to createextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘mdadm’ utility)
- Raises:
- Returns:
whether the new MD RAID device device_name was successfully created or not
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.CREATE
- Return type:
- BlockDev.md_deactivate(raid_spec)¶
- Parameters:
raid_spec (
str
) – specification of the RAID device (name, node or path)- Raises:
- Returns:
whether the RAID device raid_spec was successfully deactivated or not
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_denominate(device)¶
- Parameters:
device (
str
) – device to denominate (remove from its appropriate RAID) as a MD RAID device- Raises:
- Returns:
whether the device was successfully denominated (added to its appropriate RAID) or not
Note: may start the MD RAID if it becomes ready by adding device.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_destroy(device)¶
- Parameters:
device (
str
) – device to destroy MD RAID metadata on- Raises:
- Returns:
whether the MD RAID metadata was successfully destroyed on device or not
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.DELETE
- Return type:
- BlockDev.md_detail(raid_spec)¶
- Parameters:
raid_spec (
str
) – specification of the RAID device (name, node or path) to examine- Raises:
- Returns:
information about the MD RAID raid_spec
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.QUERY
- Return type:
- BlockDev.md_examine(device)¶
- Parameters:
device (
str
) – name of the device (a member of an MD RAID) to examine- Raises:
- Returns:
information about the MD RAID extracted from the device
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.QUERY
- Return type:
- BlockDev.md_get_bitmap_location(raid_spec)¶
- Parameters:
raid_spec (
str
) – specification of the RAID device (name, node or path) to get the bitmap location- Raises:
- Returns:
bitmap location for raid_spec
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.QUERY
- Return type:
- BlockDev.md_get_md_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to transform into format used by MD RAID- Raises:
- Returns:
transformed form of uuid
This function expects a UUID in the canonical (traditional format) and returns a UUID in the format used by MD RAID and is thus reverse to
BlockDev.md_canonicalize_uuid
(). The change is as follows: 3386ff85-f501-2621-4a43-5f061eb47236 -> 3386ff85:f5012621:4a435f06:1eb47236Tech category: always available
- Return type:
- BlockDev.md_get_status(raid_spec)¶
- Parameters:
raid_spec (
str
) – specification of the RAID device (name, node or path) to get status- Raises:
- Returns:
status of the raid_spec RAID.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.QUERY
- Return type:
- BlockDev.md_get_superblock_size(member_size, version)¶
- Parameters:
- Raises:
- Returns:
Calculated superblock size for an array with a given member_size and metadata version or default if unsupported version is used.
Tech category: always available
- Return type:
- BlockDev.md_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.MDTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.md_name_from_node(node)¶
- BlockDev.md_node_from_name(name)¶
- BlockDev.md_nominate(device)¶
- Parameters:
device (
str
) – device to nominate (add to its appropriate RAID) as a MD RAID device- Raises:
- Returns:
whether the device was successfully nominated (added to its appropriate RAID) or not
Note: may start the MD RAID if it becomes ready by adding device.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_remove(raid_spec, device, fail, extra)¶
- Parameters:
raid_spec (
str
) – specification of the RAID device (name, node or path) to remove device fromdevice (
str
) – device to remove from the raid_spec RAIDfail (
bool
) – whether to mark the device as failed before removingextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the removal (right now passed to the ‘mdadm’ utility)
- Raises:
- Returns:
whether the device was successfully removed from the raid_spec RAID or not.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_request_sync_action(raid_spec, action)¶
- Parameters:
- Raises:
- Returns:
whether the action was successfully requested for the raid_spec RAID or not.
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_run(raid_spec)¶
- Parameters:
raid_spec (
str
) – specification of the (possibly degraded) RAID device (name, node or path) to be started- Raises:
- Returns:
whether the raid_spec was successfully started or not
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.md_set_bitmap_location(raid_spec, location)¶
- Parameters:
- Raises:
- Returns:
whether location was successfully set for raid_spec
Tech category:
BlockDev.MDTech.MD_TECH_MDRAID
-BlockDev.MDTechMode.MODIFY
- Return type:
- BlockDev.mpath_flush_mpaths()¶
- Raises:
- Returns:
whether multipath device maps were successfully flushed or not
Flushes all unused multipath device maps.
Tech category:
BlockDev.MpathTech.BASE
-BlockDev.MpathTechMode.MODIFY
- Return type:
- BlockDev.mpath_get_mpath_members()¶
- Raises:
- Returns:
list of names of all devices that are members of the mpath mappings (or
None
in case of error)Tech category:
BlockDev.MpathTech.BASE
-BlockDev.MpathTechMode.QUERY
- Return type:
[
str
]
- BlockDev.mpath_is_mpath_member(device)¶
- Parameters:
device (
str
) – device to test- Raises:
- Returns:
True
if the device is a multipath member,False
if not or an error appeared when queried (error is set in those cases)Tech category:
BlockDev.MpathTech.BASE
-BlockDev.MpathTechMode.QUERY
- Return type:
- BlockDev.mpath_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.MpathTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.mpath_set_friendly_names(enabled)¶
- Parameters:
enabled (
bool
) – whether friendly names should be enabled or not- Raises:
- Returns:
if successfully set or not
Tech category:
BlockDev.MpathTech.FRIENDLY_NAMES
-BlockDev.MpathTechMode.MODIFY
- Return type:
- BlockDev.nvdimm_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.NVDIMMTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.NVDIMMTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_list_namespaces(bus, region, idle, extra)¶
- Parameters:
bus (
str
orNone
) – return only namespaces on given bus (specified by name),None
may be specified to return namespaces from all busesregion (
str
orNone
) – return only namespaces on given region (specified by regionX name or region id),None
may be specified to return namespaces from all regionsidle (
bool
) – whether to list idle (not enabled) namespaces tooextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘ndctl’ utility)
- Raises:
- Returns:
information about the namespaces on bus and region or
None
if no namespaces were found (error may be set to indicate error)Tech category:
BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE
-BlockDev.NVDIMMTechMode.QUERY
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_disable(namespace, extra)¶
- Parameters:
namespace (
str
) – name of the namespace to disableextra ([
BlockDev.ExtraArg
] orNone
) – extra options (currently unused)
- Raises:
- Returns:
whether the namespace was successfully disabled or not
Tech category:
BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE
-BlockDev.NVDIMMTechMode.ACTIVATE_DEACTIVATE
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_enable(namespace, extra)¶
- Parameters:
namespace (
str
) – name of the namespace to enableextra ([
BlockDev.ExtraArg
] orNone
) – extra options (currently unused)
- Raises:
- Returns:
whether the namespace was successfully enabled or not
Tech category:
BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE
-BlockDev.NVDIMMTechMode.ACTIVATE_DEACTIVATE
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_get_devname(device)¶
- Parameters:
device (
str
) – name or path of a block device (e.g. “/dev/pmem0”)- Raises:
- Returns:
namespace device name (e.g. “namespaceX.Y”) for device or
None
if device is not a NVDIMM namespace (error may be set to indicate error)Tech category:
BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE
-BlockDev.NVDIMMTechMode.QUERY
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_get_mode_from_str(mode_str)¶
- Parameters:
mode_str (
str
) – string representation of mode- Raises:
- Returns:
mode matching the mode_str given or
BlockDev.NVDIMMNamespaceMode.UNKNOWN
in case of no matchTech category: always available
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_get_mode_str(mode)¶
- Parameters:
mode (
BlockDev.NVDIMMNamespaceMode
) – mode to get string representation of- Raises:
- Returns:
string representation of mode or
None
in case of errorTech category: always available
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_get_supported_sector_sizes(mode)¶
- Parameters:
mode (
BlockDev.NVDIMMNamespaceMode
) – namespace mode- Raises:
- Returns:
list of supported sector sizes for mode
Tech category:
BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE
-BlockDev.NVDIMMTechMode.QUERY
- Return type:
[
int
]
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_info(namespace, extra)¶
- Parameters:
namespace (
str
) – namespace to get information aboutextra ([
BlockDev.ExtraArg
] orNone
) – extra options (currently unused)
- Raises:
- Returns:
information about given namespace or
None
if no such namespace was found (error may be set to indicate error)Tech category:
BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE
-BlockDev.NVDIMMTechMode.QUERY
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvdimm_namespace_reconfigure(namespace, mode, force, extra)¶
- Parameters:
namespace (
str
) – name of the namespace to reconfiguremode (
BlockDev.NVDIMMNamespaceMode
) – mode type to set (memory/sector/raw/dax)force (
bool
) – whether to use force to reconfigure an active namespaceextra ([
BlockDev.ExtraArg
] orNone
) – extra options for the creation (right now passed to the ‘ndctl’ utility)
- Raises:
- Returns:
whether namespace was successfully reconfigured or not
- Return type:
Deprecated since version 3.1: NVDIMM plugin will be removed in the next major release
- BlockDev.nvme_connect(subsysnqn, transport, transport_addr, transport_svcid, host_traddr, host_iface, host_nqn, host_id, extra)¶
- Parameters:
subsysnqn (
str
) – The name for the NVMe subsystem to connect to.transport (
str
) – The network fabric used for a NVMe-over-Fabrics network.transport_addr (
str
orNone
) – The network address of the Controller. For transports using IP addressing (e.g.rdma
) this should be an IP-based address.transport_svcid (
str
orNone
) – The transport service id. For transports using IP addressing (e.g.rdma
) this field is the port number. By default, the IP port number for theRDMA
transport is4420
.host_traddr (
str
orNone
) – The network address used on the host to connect to the Controller. For TCP, this sets the source address on the socket.host_iface (
str
orNone
) – The network interface used on the host to connect to the Controller (e.g. IPeth1
,enp2s0
). This forces the connection to be made on a specific interface instead of letting the system decide.host_nqn (
str
orNone
) – Overrides the default Host NQN that identifies the NVMe Host. If this option isNone
, the default is read from/etc/nvme/hostnqn
first. If that does not exist, the autogenerated NQN value from the NVMe Host kernel module is used next. The Host NQN uniquely identifies the NVMe Host.host_id (
str
orNone
) – User-defined host UUID orNone
to use default (as defined in/etc/nvme/hostid
)extra ([
BlockDev.ExtraArg
] orNone
) – Additional arguments.
- Raises:
- Returns:
True
if the subsystem was connected successfully,False
otherwise with error set.Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Creates a transport connection to a remote system (specified by transport_addr and transport_svcid) and creates a NVMe over Fabrics controller for the NVMe subsystem specified by the subsysnqn option.
Valid values for transport include:
"rdma"
: An rdma network (RoCE, iWARP, Infiniband, basic rdma, etc.)"fc"
: A Fibre Channel network."tcp"
: A TCP/IP network."loop"
: A NVMe over Fabrics target on the local host.
In addition to the primary options it’s possible to supply extra arguments:
"config"
: Use the specified JSON configuration file instead of the default file (see below) or specify"none"
to avoid reading any configuration file."dhchap_key"
: NVMe In-band authentication secret in ASCII format as described in the NVMe 2.0 specification. When not specified, the secret is by default read from/etc/nvme/hostkey
. In case that file does not exist no in-band authentication is attempted."dhchap_ctrl_key"
: NVMe In-band authentication controller secret for bi-directional authentication. When not specified, no bi-directional authentication is attempted."nr_io_queues"
: The number of I/O queues."nr_write_queues"
: Number of additional queues that will be used for write I/O."nr_poll_queues"
: Number of additional queues that will be used for polling latency sensitive I/O."queue_size"
: Number of elements in the I/O queues."keep_alive_tmo"
: The keep alive timeout (in seconds)."reconnect_delay"
: The delay (in seconds) before reconnect is attempted after a connect loss."ctrl_loss_tmo"
: The controller loss timeout period (in seconds). A special value of-1
will cause reconnecting forever."fast_io_fail_tmo"
: Fast I/O Fail timeout (in seconds)."tos"
: Type of service."duplicate_connect"
: Allow duplicated connections between same transport host and subsystem port. Boolean value."disable_sqflow"
: Disables SQ flow control to omit head doorbell update for submission queues when sending nvme completions. Boolean value."hdr_digest"
: Generates/verifies header digest (TCP). Boolean value."data_digest"
: Generates/verifies data digest (TCP). Boolean value."tls"
: Enable TLS encryption (TCP). Boolean value."hostsymname"
: TP8010: NVMe host symbolic name."keyring"
: Keyring to store and lookup keys. String value."tls_key"
: TLS PSK for the connection. String value.
Boolean values can be expressed by “0”/”1”, “on”/”off” or “True”/”False” case-insensitive strings. Failed numerical or boolean string conversions will result in the option being ignored.
By default additional options are read from the default configuration file
/etc/nvme/config.json
. This follows the default behaviour ofnvme-cli
. Use the extra"config"
argument to either specify a different config file or disable use of it. The JSON configuration file format is documented in https://raw.githubusercontent.com/linux-nvme/libnvme/master/doc/config-schema.json. As a rule extra key names are kept consistent with the JSON config file schema. Any extra option generally overrides particular option specified in a configuration file.
- BlockDev.nvme_device_self_test(device, action)¶
- Parameters:
device (
str
) – a NVMe controller or namespace device (e.g./dev/nvme0
)action (
BlockDev.NVMESelfTestAction
) – self-test action to take.
- Raises:
- Returns:
True
if the device self-test command was issued successfully,False
otherwise with error set.Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.MANAGE
- Return type:
Initiates or aborts the Device Self-test operation on the controller or a namespace, distinguished by the device path specified. In case a controller device is specified then the self-test operation would include all active namespaces.
To abort a running operation, pass
BlockDev.NVMESelfTestAction.ABORT
as action. To retrieve progress of a current running operation, check the self-test log usingBlockDev.nvme_get_self_test_log
().
- BlockDev.nvme_disconnect(subsysnqn)¶
- Parameters:
subsysnqn (
str
) – The name of the NVMe subsystem to disconnect.- Raises:
- Returns:
True
if all matching controllers were disconnected successfully,False
with error set in case of a disconnect error or when no matching controllers were found.Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Disconnects and removes one or more existing NVMe over Fabrics controllers. This may disconnect multiple controllers with matching subsysnqn and
True
is only returned when all controllers were disconnected successfully.
- BlockDev.nvme_disconnect_by_path(path)¶
- Parameters:
path (
str
) – NVMe controller device to disconnect (e.g./dev/nvme0
).- Raises:
- Returns:
True
if the controller was disconnected successfully,False
otherwise with error set.Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Disconnects and removes a NVMe over Fabrics controller represented by a block device path.
- BlockDev.nvme_find_ctrls_for_ns(ns_sysfs_path, subsysnqn, host_nqn, host_id)¶
- Parameters:
- Raises:
- Returns:
list of controller sysfs paths or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
[
str
]
A convenient utility function to look up all controllers associated with a NVMe subsystem the specified namespace is part of.
- BlockDev.nvme_format(device, lba_data_size, metadata_size, secure_erase)¶
- Parameters:
device (
str
) – NVMe namespace or controller device to format (e.g./dev/nvme0n1
)lba_data_size (
int
) – desired LBA data size (i.e. a sector size) in bytes or0
to keep current. SeeBlockDev.NVMELBAFormat
andBlockDev.nvme_get_namespace_info
().metadata_size (
int
) – desired metadata size in bytes or0
for default. SeeBlockDev.NVMELBAFormat
andBlockDev.nvme_get_namespace_info
().secure_erase (
BlockDev.NVMEFormatSecureErase
) – optional secure erase action to take.
- Raises:
- Returns:
True
if the format command finished successfully,False
otherwise with error set.Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.MANAGE
- Return type:
Performs low level format of the NVM media, destroying all data and metadata for either a specific namespace or all attached namespaces to the controller. Use this command to change LBA sector size. Optional secure erase method can be specified as well.
Supported LBA data sizes for a given namespace can be listed using the
BlockDev.nvme_get_namespace_info
() call. In case of a special value0
the current LBA format for a given namespace will be retained. When called on a controller device the first namespace is used as a reference.Note that the NVMe controller may define a Format NVM attribute indicating that the format operation would apply to all namespaces and a format (excluding secure erase) of any namespace results in a format of all namespaces in the NVM subsystem. In such case and when device is a namespace block device the
BlockDev.NVMEError.WOULD_FORMAT_ALL_NS
error is returned to prevent further damage. This is then supposed to be handled by the caller andBlockDev.nvme_format
() is supposed to be called on a controller device instead.This call blocks until the format operation has finished. To retrieve progress of a current running operation, check the namespace info using
BlockDev.nvme_get_namespace_info
().
- BlockDev.nvme_generate_host_nqn()¶
- Raises:
- Returns:
the Host NQN string or
None
with error set.Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Compute new Host NQN (NVM Qualified Name) value for the current system. This takes in account various system identifiers (DMI, device tree) with the goal of a stable unique identifier whenever feasible.
- BlockDev.nvme_get_controller_info(device)¶
- Parameters:
device (
str
) – a NVMe controller device (e.g./dev/nvme0
)- Raises:
- Returns:
information about given controller or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.INFO
- Return type:
Retrieves information about the NVMe controller (the Identify Controller command) as specified by the device block device path.
- BlockDev.nvme_get_error_log_entries(device)¶
- Parameters:
device (
str
) – a NVMe controller device (e.g./dev/nvme0
)- Raises:
- Returns:
null-terminated list of error entries or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.INFO
- Return type:
Retrieves Error Information Log (Log Identifier
01h
) entries, used to describe extended error information for a command that completed with error or to report an error that is not specific to a particular command. This log is global to the controller. The ordering of the entries is based on the time when the error occurred, with the most recent error being returned as the first log entry. As the number of entries is typically limited by the drive implementation, only most recent entries are provided.
- BlockDev.nvme_get_host_id()¶
- Raises:
- Returns:
the Host ID string or an empty string if none set.
Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Reads the Host ID value from the global
/etc/nvme/hostid
file. An empty string is an indication that no Host ID has been set.
- BlockDev.nvme_get_host_nqn()¶
- Raises:
- Returns:
the Host NQN string or an empty string if none set.
Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Reads the Host NQN (NVM Qualified Name) value from the global
/etc/nvme/hostnqn
file. An empty string is an indication that no Host NQN has been set.
- BlockDev.nvme_get_namespace_info(device)¶
- Parameters:
device (
str
) – a NVMe namespace device (e.g./dev/nvme0n1
)- Raises:
- Returns:
information about given namespace or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.INFO
- Return type:
Retrieves information about the NVMe namespace (the Identify Namespace command) as specified by the device block device path.
- BlockDev.nvme_get_sanitize_log(device)¶
- Parameters:
device (
str
) – a NVMe controller device (e.g./dev/nvme0
)- Raises:
- Returns:
sanitize log data or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.INFO
- Return type:
Retrieves the drive sanitize status log (Log Identifier
81h
) that includes information about the most recent sanitize operation and the sanitize operation time estimates.As advised in the NVMe specification whitepaper the host should limit polling to retrieve progress of a running sanitize operations (e.g. to at most once every several minutes) to avoid interfering with the progress of the sanitize operation itself.
- BlockDev.nvme_get_self_test_log(device)¶
- Parameters:
device (
str
) – a NVMe controller device (e.g./dev/nvme0
)- Raises:
- Returns:
self-test log data or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.INFO
- Return type:
Retrieves drive self-test log (Log Identifier
06h
). Provides the status of a self-test operation in progress and the percentage complete of that operation, along with the results of the last 20 device self-test operations.
- BlockDev.nvme_get_smart_log(device)¶
- Parameters:
device (
str
) – a NVMe controller device (e.g./dev/nvme0
)- Raises:
- Returns:
health log data or
None
in case of an error (with error set).Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.INFO
- Return type:
Retrieves drive SMART and general health information (Log Identifier
02h
). The information provided is over the life of the controller and is retained across power cycles.
- BlockDev.nvme_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.NVMETech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.NVMETechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.nvme_sanitize(device, action, no_dealloc, overwrite_pass_count, overwrite_pattern, overwrite_invert_pattern)¶
- Parameters:
device (
str
) – NVMe namespace or controller device to format (e.g./dev/nvme0n1
)action (
BlockDev.NVMESanitizeAction
) – the sanitize action to perform.no_dealloc (
bool
) – instruct the controller to not deallocate the affected media area.overwrite_pass_count (
int
) – number of overwrite passes [1-15] or 0 for the default (16 passes).overwrite_pattern (
int
) – a 32-bit pattern used for the Overwrite sanitize operation.overwrite_invert_pattern (
bool
) – invert the overwrite pattern between passes.
- Raises:
- Returns:
True
if the format command finished successfully,False
otherwise with error set.Tech category:
BlockDev.NVMETech.NVME
-BlockDev.NVMETechMode.MANAGE
- Return type:
Starts a sanitize operation or recovers from a previously failed sanitize operation. By definition, a sanitize operation alters all user data in the NVM subsystem such that recovery of any previous user data from any cache, the non-volatile media, or any Controller Memory Buffer is not possible. The scope of a sanitize operation is all locations in the NVM subsystem that are able to contain user data, including caches, Persistent Memory Regions, and unallocated or deallocated areas of the media.
Once started, a sanitize operation is not able to be aborted and continues after a Controller Level Reset including across power cycles. Once the sanitize operation has run the media affected may not be immediately ready for use unless additional media modification mechanism is run. This is often vendor specific and also depends on the sanitize method (action) used. Callers to this sanitize operation should set no_dealloc to
True
for the added convenience.The controller also ignores Critical Warning(s) in the SMART / Health Information log page (e.g., read only mode) and attempts to complete the sanitize operation requested.
This call returns immediately and the actual sanitize operation is performed in the background. Use
BlockDev.nvme_get_sanitize_log
() to retrieve status and progress of a running sanitize operation. In case a sanitize operation fails the controller may restrict its operation until a subsequent sanitize operation is started (i.e. retried) or anBlockDev.NVMESanitizeAction.EXIT_FAILURE
action is used to acknowledge the failure explicitly.The overwrite_pass_count, overwrite_pattern and overwrite_invert_pattern arguments are only valid when action is
BlockDev.NVMESanitizeAction.OVERWRITE
.The sanitize operation is set to run under the Allow Unrestricted Sanitize Exit mode.
- BlockDev.nvme_self_test_result_to_string(result)¶
- Parameters:
result (
BlockDev.NVMESelfTestResult
) – ABlockDev.NVMESelfTestResult
.- Raises:
- Returns:
A string representation of result for use as an identifier string or
None
when the code is unknown.- Return type:
- BlockDev.nvme_set_host_id(host_id)¶
- Parameters:
host_id (
str
) – The Host ID.- Raises:
- Returns:
True
if the value was set successfully orFalse
otherwise with error set.Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Writes the Host ID value to the system
/etc/nvme/hostid
file. No validation of the string is performed.
- BlockDev.nvme_set_host_nqn(host_nqn)¶
- Parameters:
host_nqn (
str
) – The Host NVM Qualified Name.- Raises:
- Returns:
True
if the value was set successfully orFalse
otherwise with error set.Tech category:
BlockDev.NVMETech.FABRICS
-BlockDev.NVMETechMode.INITIATOR
- Return type:
Writes the Host NQN (NVM Qualified Name) value to the system
/etc/nvme/hostnqn
file. No validation of the string is performed.
- BlockDev.part_create_part(disk, type, start, size, align)¶
- Parameters:
disk (
str
) – disk to create partition ontype (
BlockDev.PartTypeReq
) – type of the partition to create (ifBlockDev.PartTypeReq.NEXT
, the partition type will be determined automatically based on the existing partitions)start (
int
) – where the partition should start (i.e. offset from the disk start)size (
int
) – desired size of the partition (if 0, a max-sized partition is created)align (
BlockDev.PartAlign
) – alignment to use for the partition
- Raises:
- Returns:
specification of the created partition or
None
in case of errorNOTE: The resulting partition may start at a different position than given by start and can have different size than size due to alignment.
Tech category:
BlockDev.PartTechMode.MODIFY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_create_table(disk, type, ignore_existing)¶
- Parameters:
disk (
str
) – path of the disk block device to create partition table ontype (
BlockDev.PartTableType
) – type of the partition table to createignore_existing (
bool
) – whether to ignore/overwrite the existing table or not (reports an error ifFalse
and there’s some table on disk)
- Raises:
- Returns:
whether the partition table was successfully created or not
Tech category:
BlockDev.PartTechMode.CREATE_TABLE
+ the tech according to type- Return type:
- BlockDev.part_delete_part(disk, part)¶
- Parameters:
- Raises:
- Returns:
whether the part partition was successfully deleted from disk
Tech category:
BlockDev.PartTechMode.MODIFY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_best_free_region(disk, type, size)¶
- Parameters:
disk (
str
) – disk to get the best free region fortype (
BlockDev.PartType
) – type of the partition that is planned to be addedsize (
int
) – size of the partition to be added
- Raises:
- Returns:
spec of the best free region on disk for a new partition of type type with the size of size or
None
if there is none such region or if there was an error (error gets populated)Note: For the type
BlockDev.PartType.NORMAL
, the smallest possible space that *is not* in an extended partition is found. For the typeBlockDev.PartType.LOGICAL
, the smallest possible space that *is* in an extended partition is found. ForBlockDev.PartType.EXTENDED
, the biggest possible space is found as long as there is no other extended partition (there can only be one).Tech category:
BlockDev.PartTechMode.QUERY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_disk_free_regions(disk)¶
- Parameters:
disk (
str
) – disk to get free regions for- Raises:
- Returns:
specs of the free regions from disk or
None
in case of errorTech category:
BlockDev.PartTechMode.QUERY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_disk_parts(disk)¶
- Parameters:
disk (
str
) – disk to get information about partitions for- Raises:
- Returns:
specs of the partitions from disk or
None
in case of errorTech category:
BlockDev.PartTechMode.QUERY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_disk_spec(disk)¶
- Parameters:
disk (
str
) – disk to get information about- Raises:
- Returns:
information about the given disk or
None
(in case of error)Tech category:
BlockDev.PartTechMode.QUERY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_part_by_pos(disk, position)¶
- Parameters:
- Raises:
- Returns:
spec of the partition from disk spanning over the position or
None
if no such partition exists or in case of error (error is set)Tech category:
BlockDev.PartTechMode.QUERY_PART
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_part_spec(disk, part)¶
- Parameters:
- Raises:
- Returns:
spec of the part partition from disk or
None
in case of errorTech category:
BlockDev.PartTechMode.QUERY_PART
+ the tech according to the partition table type- Return type:
- BlockDev.part_get_part_table_type_str(type)¶
- Parameters:
type (
BlockDev.PartTableType
) – table type to get string representation for- Raises:
- Returns:
string representation of table_type
Tech category: the tech according to type
- Return type:
- BlockDev.part_get_type_str(type)¶
- Parameters:
type (
BlockDev.PartType
) – type to get string representation for- Raises:
- Returns:
string representation of type
Tech category: always available
- Return type:
- BlockDev.part_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.PartTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.PartTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.part_resize_part(disk, part, size, align)¶
- Parameters:
disk (
str
) – disk containing the partitionpart (
str
) – partition to resizesize (
int
) – new partition size, 0 for maximal sizealign (
BlockDev.PartAlign
) – alignment to use for the partition end
- Raises:
- Returns:
whether the part partition was successfully resized on disk to size
NOTE: The resulting partition may be slightly bigger than requested due to alignment.
Tech category:
BlockDev.PartTechMode.MODIFY_TABLE
+ the tech according to the partition table type- Return type:
- BlockDev.part_set_part_attributes(disk, part, attrs)¶
- Parameters:
- Raises:
- Returns:
whether the attrs GPT attributes were successfully set for part or not
Tech category:
BlockDev.PartTech.GPT
-BlockDev.PartTechMode.MODIFY_PART
- Return type:
- BlockDev.part_set_part_bootable(disk, part, bootable)¶
- Parameters:
- Raises:
- Returns:
whether the bootable flag was successfully set for part or not
Tech category:
BlockDev.PartTech.MBR
-BlockDev.PartTechMode.MODIFY_PART
- Return type:
- BlockDev.part_set_part_id(disk, part, part_id)¶
- Parameters:
- Raises:
- Returns:
whether the part_id type was successfully set for part or not
Tech category:
BlockDev.PartTech.MBR
-BlockDev.PartTechMode.MODIFY_PART
- Return type:
- BlockDev.part_set_part_name(disk, part, name)¶
- Parameters:
- Raises:
- Returns:
whether the name was successfully set or not
Tech category:
BlockDev.PartTech.GPT
-BlockDev.PartTechMode.MODIFY_PART
- Return type:
- BlockDev.part_set_part_type(disk, part, type_guid)¶
- Parameters:
- Raises:
- Returns:
whether the type_guid type was successfully set for part or not
Tech category:
BlockDev.PartTech.GPT
-BlockDev.PartTechMode.MODIFY_PART
- Return type:
- BlockDev.part_set_part_uuid(disk, part, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the uuid type was successfully set for part or not
Tech category:
BlockDev.PartTechMode.MODIFY_PART
+ the tech according to the partition table type- Return type:
- BlockDev.reinit(require_plugins, reload, log_func)¶
- Parameters:
require_plugins ([
BlockDev.PluginSpec
] orNone
) –None
-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) orNone
to load all pluginsreload (
bool
) – whether to reload the already loaded plugins or notlog_func (
BlockDev.UtilsLogFunc
orNone
) – logging function to use orNone
to keep the old one
- Raises:
- Returns:
whether the library was successfully initialized or not
If reload is
True
all the plugins are closed and reloaded otherwise only the missing plugins are loaded.- Return type:
- BlockDev.swap_check_label(label)¶
- Parameters:
label (
str
) – label to check- Raises:
- Returns:
whether label is a valid label for swap or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.swap_check_uuid(uuid)¶
- Parameters:
uuid (
str
) – UUID to check- Raises:
- Returns:
whether uuid is a valid UUID for swap or not (reason is provided in error)
Tech category: always available
- Return type:
- BlockDev.swap_is_tech_avail(tech, mode)¶
- Parameters:
tech (
BlockDev.SwapTech
) – the queried techmode (
int
) – a bit mask of queried modes of operation (BlockDev.SwapTechMode
) for tech
- Raises:
- Returns:
whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available
- Return type:
- BlockDev.swap_mkswap(device, label, uuid, extra)¶
- Parameters:
- Raises:
- Returns:
whether the swap space was successfully created or not
Tech category:
BlockDev.SwapTech.SWAP_TECH_SWAP
-BlockDev.SwapTechMode.CREATE
- Return type:
- BlockDev.swap_set_label(device, label)¶
- Parameters:
- Raises:
- Returns:
whether the label was successfully set or not
Tech category:
BlockDev.SwapTech.SWAP_TECH_SWAP
-BlockDev.SwapTechMode.SET_LABEL
- Return type:
- BlockDev.swap_set_uuid(device, uuid)¶
- Parameters:
- Raises:
- Returns:
whether the UUID was successfully set or not
Tech category:
BlockDev.SwapTech.SWAP_TECH_SWAP
-BlockDev.SwapTechMode.SET_UUID
- Return type:
- BlockDev.swap_swapoff(device)¶
- Parameters:
device (
str
) – swap device to deactivate- Raises:
- Returns:
whether the swap device was successfully deactivated or not
Tech category:
BlockDev.SwapTech.SWAP_TECH_SWAP
-BlockDev.SwapTechMode.ACTIVATE_DEACTIVATE
- Return type:
- BlockDev.swap_swapon(device, priority)¶
- Parameters:
- Raises:
- Returns:
whether the swap device was successfully activated or not
Tech category:
BlockDev.SwapTech.SWAP_TECH_SWAP
-BlockDev.SwapTechMode.ACTIVATE_DEACTIVATE
- Return type:
- BlockDev.swap_swapstatus(device)¶
- Parameters:
device (
str
) – swap device to get status of- Raises:
- Returns:
True
if the swap device is active,False
if not active or failed to determine (error) is set not a non-None
value in such case)Tech category:
BlockDev.SwapTech.SWAP_TECH_SWAP
-BlockDev.SwapTechMode.QUERY
- Return type:
- BlockDev.try_init(request_plugins, log_func)¶
- Parameters:
request_plugins ([
BlockDev.PluginSpec
] orNone
) –None
-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) orNone
to load all pluginslog_func (
BlockDev.UtilsLogFunc
orNone
) – logging function to use
- Raises:
- Returns:
whether the library was successfully initialized with all the required or default (see require_plugins) plugins or not
*UNLIKE IN CASE OF
BlockDev.init
() ANDBlockDev.ensure_init
(), FAILURE TO LOAD A PLUGIN IS NOT CONSIDERED ERROR*- loaded_plugin_names:
names of the successfully loaded plugins
- Return type:
- BlockDev.try_reinit(require_plugins, reload, log_func)¶
- Parameters:
require_plugins ([
BlockDev.PluginSpec
] orNone
) –None
-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) orNone
to load all pluginsreload (
bool
) – whether to reload the already loaded plugins or notlog_func (
BlockDev.UtilsLogFunc
orNone
) – logging function to use orNone
to keep the old one
- Raises:
- Returns:
whether the library was successfully initialized or not
If reload is
True
all the plugins are closed and reloaded otherwise only the missing plugins are loaded.*UNLIKE IN CASE OF
BlockDev.init
() ANDBlockDev.ensure_init
(), FAILURE TO LOAD A PLUGIN IS NOT CONSIDERED ERROR*- loaded_plugin_names:
names of the successfully loaded plugins
- Return type:
- BlockDev.utils_check_linux_version(major, minor, micro)¶
- Parameters:
- Returns:
an integer less than, equal to, or greater than zero, if detected version is <, == or > than the specified major.`minor`.`micro` version.
- Return type:
Checks whether the currently running linux kernel version is equal or higher than the specified required major.`minor`.`micro` version.
- BlockDev.utils_check_util_version(util, version, version_arg, version_regexp)¶
- Parameters:
util (
str
) – name of the utility to checkversion (
str
orNone
) – minimum required version of the utility orNone
if no version is requiredversion_arg (
str
orNone
) – argument to use with the util to get version info orNone
to use “–version”version_regexp (
str
orNone
) – regexp to extract version from the version info orNone
if only version is printed by “$ util version_arg"
- Raises:
- Returns:
whether the util is available in a version >= version or not (error is set in such case).
- Return type:
- BlockDev.utils_dbus_service_available(connection, bus_type, bus_name, obj_prefix)¶
- Parameters:
connection (
Gio.DBusConnection
orNone
) – existingGio.DBusConnection
orNone
bus_type (
Gio.BusType
) – bus type (system or session), ignored if connection is specifiedbus_name (
str
) – name of the service to check (e.g. “com.redhat.lvmdbus1”)obj_prefix (
str
) – object path prefix for the service (e.g. “/com/redhat/lvmdbus1”)
- Raises:
- Returns:
whether the service was found in the system
- Return type:
- BlockDev.utils_echo_str_to_file(str, file_path)¶
- Parameters:
- Raises:
- Returns:
whether the str was successfully written to file_path or not.
- Return type:
- BlockDev.utils_exec_and_capture_output(argv, extra)¶
- Parameters:
argv ([
str
]) – the argv array for the callextra ([
BlockDev.ExtraArg
] orNone
) – extra arguments
- Raises:
- Returns:
whether the argv was successfully executed capturing the output or not
- output:
variable to store output to
- Return type:
Note that any
None
bytes read from standard output and standard error output will be discarded.
- BlockDev.utils_exec_and_report_error(argv, extra)¶
- Parameters:
argv ([
str
]) – the argv array for the callextra ([
BlockDev.ExtraArg
] orNone
) – extra arguments
- Raises:
- Returns:
whether the argv was successfully executed (no error and exit code 0) or not
- Return type:
- BlockDev.utils_exec_and_report_error_no_progress(argv, extra)¶
- Parameters:
argv ([
str
]) – the argv array for the callextra ([
BlockDev.ExtraArg
] orNone
) – extra arguments
- Raises:
- Returns:
whether the argv was successfully executed (no error and exit code 0) or not
- Return type:
- BlockDev.utils_exec_and_report_progress(argv, extra, prog_extract)¶
- Parameters:
argv ([
str
]) – the argv array for the callextra ([
BlockDev.ExtraArg
] orNone
) – extra argumentsprog_extract (
BlockDev.UtilsProgExtract
orNone
) – function for extracting progress information
- Raises:
- Returns:
whether the argv was successfully executed (no error and exit code 0) or not
- proc_status:
place to store the process exit status
- Return type:
Note that any
None
bytes read from standard output and standard error output are treated as separators similar to newlines and prog_extract will be called with the respective chunk.
- BlockDev.utils_exec_and_report_status_error(argv, extra)¶
- Parameters:
argv ([
str
]) – the argv array for the callextra ([
BlockDev.ExtraArg
] orNone
) – extra arguments
- Raises:
- Returns:
whether the argv was successfully executed (no error and exit code 0) or not
- status:
place to store the status
- Return type:
- BlockDev.utils_exec_with_input(argv, input, extra)¶
- Parameters:
argv ([
str
]) – the argv array for the callextra ([
BlockDev.ExtraArg
] orNone
) – extra arguments
- Raises:
- Returns:
whether the argv was successfully executed (no error and exit code 0) or not
- Return type:
- BlockDev.utils_get_device_symlinks(dev_spec)¶
- BlockDev.utils_get_linux_version()¶
- Raises:
- Returns:
Detected Linux kernel version or
None
in case of an error. The returned value belongs to the library, do not free.- Return type:
Retrieves version of currently running Linux kernel. Acts also as an initializer for statically cached data.
- BlockDev.utils_have_kernel_module(module_name)¶
- Parameters:
module_name (
str
) – name of the kernel module to check- Raises:
- Returns:
whether the module_name was found in the system, either as a module or built-in in the kernel
- Return type:
- BlockDev.utils_init_logging(new_log_func)¶
- Parameters:
new_log_func (
BlockDev.UtilsLogFunc
orNone
) – logging function to use orNone
to disable logging; useBlockDev.utils_log_stdout
to reset to the default behaviour- Raises:
- Returns:
whether logging was successfully initialized or not
- Return type:
- BlockDev.utils_init_prog_reporting(new_prog_func)¶
- Parameters:
new_prog_func (
BlockDev.UtilsProgFunc
orNone
) – progress reporting function to use orNone
to reset to default- Raises:
- Returns:
whether progress reporting was successfully initialized or not
- Return type:
- BlockDev.utils_init_prog_reporting_thread(new_prog_func)¶
- Parameters:
new_prog_func (
BlockDev.UtilsProgFunc
orNone
) – progress reporting function to use on current thread orNone
to reset to default or global- Raises:
- Returns:
whether progress reporting was successfully initialized or not
- Return type:
- BlockDev.utils_load_kernel_module(module_name, options)¶
- Parameters:
- Raises:
- Returns:
whether the module_name was successfully loaded or not
- Return type:
- BlockDev.utils_log_stdout(level, msg)¶
-
Convenient function for logging to stdout. Can be used as
BlockDev.UtilsLogFunc
.
- BlockDev.utils_log_task_status(task_id, msg)¶
- BlockDev.utils_mute_prog_reporting_thread()¶
- Raises:
- Returns:
whether progress reporting for the current thread was successfully muted (deinitialized even in presence of a global reporting function) or not
- Return type:
- BlockDev.utils_prog_reporting_initialized()¶
- Returns:
True
if progress reporting has been initialized, i.e. a reporting function was set up with eitherBlockDev.utils_init_prog_reporting
orBlockDev.utils_init_prog_reporting_thread
(takes precedence).False
ifBlockDev.utils_mute_prog_reporting_thread
was used to mute the thread.- Return type:
- BlockDev.utils_report_finished(task_id, msg)¶
- BlockDev.utils_report_progress(task_id, completion, msg)¶
- BlockDev.utils_report_started(msg)¶
- BlockDev.utils_resolve_device(dev_spec)¶
- BlockDev.utils_set_log_level(level)¶
- Parameters:
level (
int
) – log level
Level of messages to log. Only messages with level <= level will be logged. For example using with
BlockDev.UTILS_LOG_WARNING
(default value) only messages with log levelsBlockDev.UTILS_LOG_WARNING
,BlockDev.UTILS_LOG_ERR
, …,BlockDev.UTILS_LOG_EMERG
will be logged.Note:
BlockDev.UTILS_LOG_DEBUG
level messages are always skipped unless compiled with--enable-debug
configure option.
- BlockDev.utils_unload_kernel_module(module_name)¶
- Parameters:
module_name (
str
) – name of the kernel module to unload- Raises:
- Returns:
whether the module_name was successfully unloaded or not
- Return type:
- BlockDev.utils_version_cmp(ver_string1, ver_string2)¶
- Parameters:
- Raises:
- Returns:
-1, 0 or 1 if ver_string1 is lower, the same or higher version as ver_string2 respectively. If an error occurs, returns -2 and error is set.
**ONLY SUPPORTS VERSION STRINGS OF FORMAT
X[.Y[.Z[.Z2[.Z3...[-R]]]]]
where all components are natural numbers!**- Return type: