Functions

btrfs_add_device (mountpoint, device, extra)

btrfs_change_label (mountpoint, label)

btrfs_check (device, extra)

btrfs_create_snapshot (source, dest, ro, extra)

btrfs_create_subvolume (mountpoint, name, extra)

btrfs_create_volume (devices, label, data_level, md_level, extra)

btrfs_delete_subvolume (mountpoint, name, extra)

btrfs_error_quark ()

btrfs_filesystem_info (device)

btrfs_get_default_subvolume_id (mountpoint)

btrfs_is_tech_avail (tech, mode)

btrfs_list_devices (device)

btrfs_list_subvolumes (mountpoint, snapshots_only)

btrfs_mkfs (devices, label, data_level, md_level, extra)

btrfs_remove_device (mountpoint, device, extra)

btrfs_repair (device, extra)

btrfs_resize (mountpoint, size, extra)

btrfs_set_default_subvolume (mountpoint, subvol_id, extra)

crypto_bitlk_close (bitlk_device)

crypto_bitlk_info (device)

crypto_bitlk_open (device, name, context, read_only)

crypto_device_is_luks (device)

crypto_device_seems_encrypted (device)

crypto_error_quark ()

crypto_escrow_device (device, passphrase, cert_data, directory, backup_passphrase)

crypto_fvault2_close (fvault2_device)

crypto_fvault2_open (device, name, context, read_only)

crypto_generate_backup_passphrase ()

crypto_integrity_close (integrity_device)

crypto_integrity_format (device, algorithm, wipe, context, extra)

crypto_integrity_info (device)

crypto_integrity_open (device, name, algorithm, context, flags, extra)

crypto_is_tech_avail (tech, mode)

crypto_keyring_add_key (key_desc, key_data)

crypto_luks_add_key (device, context, ncontext)

crypto_luks_change_key (device, context, ncontext)

crypto_luks_close (luks_device)

crypto_luks_format (device, cipher, key_size, context, min_entropy, luks_version, extra)

crypto_luks_header_backup (device, backup_file)

crypto_luks_header_restore (device, backup_file)

crypto_luks_info (device)

crypto_luks_kill_slot (device, slot)

crypto_luks_open (device, name, context, read_only)

crypto_luks_remove_key (device, context)

crypto_luks_resize (luks_device, size, context)

crypto_luks_resume (luks_device, context)

crypto_luks_set_label (device, label, subsystem)

crypto_luks_set_uuid (device, uuid)

crypto_luks_status (luks_device)

crypto_luks_suspend (luks_device)

crypto_luks_token_info (device)

crypto_tc_close (tc_device)

crypto_tc_open (device, name, context, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only)

dm_create_linear (map_name, device, length, uuid)

dm_error_quark ()

dm_get_subsystem_from_name (device_name)

dm_is_tech_avail (tech, mode)

dm_map_exists (map_name, live_only, active_only)

dm_name_from_node (dm_node)

dm_node_from_name (map_name)

dm_remove (map_name)

ensure_init (require_plugins, log_func)

extra_arg_list_free (args)

fs_btrfs_check (device, extra)

fs_btrfs_check_label (label)

fs_btrfs_check_uuid (uuid)

fs_btrfs_get_info (mpoint)

fs_btrfs_mkfs (device, extra)

fs_btrfs_repair (device, extra)

fs_btrfs_resize (mpoint, new_size, extra)

fs_btrfs_set_label (mpoint, label)

fs_btrfs_set_uuid (device, uuid)

fs_can_check (type)

fs_can_get_free_space (type)

fs_can_get_size (type)

fs_can_mkfs (type)

fs_can_repair (type)

fs_can_resize (type)

fs_can_set_label (type)

fs_can_set_uuid (type)

fs_check (device, fstype)

fs_check_label (fstype, label)

fs_check_uuid (fstype, uuid)

fs_clean (device, force)

fs_error_quark ()

fs_exfat_check (device, extra)

fs_exfat_check_label (label)

fs_exfat_check_uuid (uuid)

fs_exfat_get_info (device)

fs_exfat_mkfs (device, extra)

fs_exfat_repair (device, extra)

fs_exfat_set_label (device, label)

fs_exfat_set_uuid (device, uuid)

fs_ext2_check (device, extra)

fs_ext2_check_label (label)

fs_ext2_check_uuid (uuid)

fs_ext2_get_info (device)

fs_ext2_mkfs (device, extra)

fs_ext2_repair (device, unsafe, extra)

fs_ext2_resize (device, new_size, extra)

fs_ext2_set_label (device, label)

fs_ext2_set_uuid (device, uuid)

fs_ext3_check (device, extra)

fs_ext3_check_label (label)

fs_ext3_check_uuid (uuid)

fs_ext3_get_info (device)

fs_ext3_mkfs (device, extra)

fs_ext3_repair (device, unsafe, extra)

fs_ext3_resize (device, new_size, extra)

fs_ext3_set_label (device, label)

fs_ext3_set_uuid (device, uuid)

fs_ext4_check (device, extra)

fs_ext4_check_label (label)

fs_ext4_check_uuid (uuid)

fs_ext4_get_info (device)

fs_ext4_mkfs (device, extra)

fs_ext4_repair (device, unsafe, extra)

fs_ext4_resize (device, new_size, extra)

fs_ext4_set_label (device, label)

fs_ext4_set_uuid (device, uuid)

fs_f2fs_check (device, extra)

fs_f2fs_get_info (device)

fs_f2fs_mkfs (device, extra)

fs_f2fs_repair (device, extra)

fs_f2fs_resize (device, new_size, safe, extra)

fs_features (fstype)

fs_freeze (mountpoint)

fs_get_free_space (device, fstype)

fs_get_fstype (device)

fs_get_mountpoint (device)

fs_get_size (device, fstype)

fs_is_mountpoint (path)

fs_is_tech_avail (tech, mode)

fs_mkfs (device, fstype, options, extra)

fs_mount (device, mountpoint, fstype, options, extra)

fs_nilfs2_check_label (label)

fs_nilfs2_check_uuid (uuid)

fs_nilfs2_get_info (device)

fs_nilfs2_mkfs (device, extra)

fs_nilfs2_resize (device, new_size)

fs_nilfs2_set_label (device, label)

fs_nilfs2_set_uuid (device, uuid)

fs_ntfs_check (device, extra)

fs_ntfs_check_label (label)

fs_ntfs_check_uuid (uuid)

fs_ntfs_get_info (device)

fs_ntfs_mkfs (device, extra)

fs_ntfs_repair (device, extra)

fs_ntfs_resize (device, new_size)

fs_ntfs_set_label (device, label)

fs_ntfs_set_uuid (device, uuid)

fs_repair (device, fstype)

fs_resize (device, new_size, fstype)

fs_set_label (device, label, fstype)

fs_set_uuid (device, uuid, fstype)

fs_supported_filesystems ()

fs_udf_check_label (label)

fs_udf_check_uuid (uuid)

fs_udf_get_info (device)

fs_udf_mkfs (device, media_type, revision, block_size, extra)

fs_udf_set_label (device, label)

fs_udf_set_uuid (device, uuid)

fs_unfreeze (mountpoint)

fs_unmount (spec, lazy, force, extra)

fs_vfat_check (device, extra)

fs_vfat_check_label (label)

fs_vfat_check_uuid (uuid)

fs_vfat_get_info (device)

fs_vfat_mkfs (device, extra)

fs_vfat_repair (device, extra)

fs_vfat_resize (device, new_size)

fs_vfat_set_label (device, label)

fs_vfat_set_uuid (device, uuid)

fs_wipe (device, all, force)

fs_xfs_check (device, extra)

fs_xfs_check_label (label)

fs_xfs_check_uuid (uuid)

fs_xfs_get_info (device)

fs_xfs_mkfs (device, extra)

fs_xfs_repair (device, extra)

fs_xfs_resize (mpoint, new_size, extra)

fs_xfs_set_label (device, label)

fs_xfs_set_uuid (device, uuid)

get_available_plugin_names ()

get_plugin_name (plugin)

get_plugin_soname (plugin)

init (require_plugins, log_func)

is_initialized ()

is_plugin_available (plugin)

loop_error_quark ()

loop_get_loop_name (file)

loop_info (loop)

loop_is_tech_avail (tech, mode)

loop_set_autoclear (loop, autoclear)

loop_setup (file, offset, size, read_only, part_scan, sector_size)

loop_setup_from_fd (fd, offset, size, read_only, part_scan, sector_size)

loop_teardown (loop)

lvm_add_lv_tags (vg_name, lv_name, tags)

lvm_add_pv_tags (device, tags)

lvm_add_vg_tags (vg_name, tags)

lvm_cache_attach (vg_name, data_lv, cache_pool_lv, extra)

lvm_cache_create_cached_lv (vg_name, lv_name, data_size, cache_size, md_size, mode, flags, slow_pvs, fast_pvs)

lvm_cache_create_pool (vg_name, pool_name, pool_size, md_size, mode, flags, fast_pvs)

lvm_cache_detach (vg_name, cached_lv, destroy, extra)

lvm_cache_get_default_md_size (cache_size)

lvm_cache_get_mode_from_str (mode_str)

lvm_cache_get_mode_str (mode)

lvm_cache_pool_convert (vg_name, data_lv, metadata_lv, name, extra)

lvm_cache_pool_name (vg_name, cached_lv)

lvm_cache_stats (vg_name, cached_lv)

lvm_delete_lv_tags (vg_name, lv_name, tags)

lvm_delete_pv_tags (device, tags)

lvm_delete_vg_tags (vg_name, tags)

lvm_devices_add (device, devices_file, extra)

lvm_devices_delete (device, devices_file, extra)

lvm_error_quark ()

lvm_get_devices_filter ()

lvm_get_global_config ()

lvm_get_lv_physical_size (lv_size, pe_size)

lvm_get_max_lv_size ()

lvm_get_supported_pe_sizes ()

lvm_get_thpool_meta_size (size, chunk_size, n_snapshots)

lvm_get_thpool_padding (size, pe_size, included)

lvm_get_vdo_compression_state_str (state)

lvm_get_vdo_index_state_str (state)

lvm_get_vdo_operating_mode_str (mode)

lvm_get_vdo_write_policy_from_str (policy_str)

lvm_get_vdo_write_policy_str (policy)

lvm_is_supported_pe_size (size)

lvm_is_tech_avail (tech, mode)

lvm_is_valid_thpool_chunk_size (size, discard)

lvm_is_valid_thpool_md_size (size)

lvm_lvactivate (vg_name, lv_name, ignore_skip, shared, extra)

lvm_lvcreate (vg_name, lv_name, size, type, pv_list, extra)

lvm_lvdeactivate (vg_name, lv_name, extra)

lvm_lvinfo (vg_name, lv_name)

lvm_lvinfo_tree (vg_name, lv_name)

lvm_lvorigin (vg_name, lv_name)

lvm_lvremove (vg_name, lv_name, force, extra)

lvm_lvrename (vg_name, lv_name, new_name, extra)

lvm_lvrepair (vg_name, lv_name, pv_list, extra)

lvm_lvresize (vg_name, lv_name, size, extra)

lvm_lvs (vg_name)

lvm_lvs_tree (vg_name)

lvm_lvsnapshotcreate (vg_name, origin_name, snapshot_name, size, extra)

lvm_lvsnapshotmerge (vg_name, snapshot_name, extra)

lvm_pvcreate (device, data_alignment, metadata_size, extra)

lvm_pvinfo (device)

lvm_pvmove (src, dest, extra)

lvm_pvremove (device, extra)

lvm_pvresize (device, size, extra)

lvm_pvs ()

lvm_pvscan (device, update_cache, extra)

lvm_round_size_to_pe (size, pe_size, roundup)

lvm_set_devices_filter (devices)

lvm_set_global_config (new_config)

lvm_thlvcreate (vg_name, pool_name, lv_name, size, extra)

lvm_thlvpoolname (vg_name, lv_name)

lvm_thpool_convert (vg_name, data_lv, metadata_lv, name, extra)

lvm_thpoolcreate (vg_name, lv_name, size, md_size, chunk_size, profile, extra)

lvm_thsnapshotcreate (vg_name, origin_name, snapshot_name, pool_name, extra)

lvm_vdo_disable_compression (vg_name, pool_name, extra)

lvm_vdo_disable_deduplication (vg_name, pool_name, extra)

lvm_vdo_enable_compression (vg_name, pool_name, extra)

lvm_vdo_enable_deduplication (vg_name, pool_name, extra)

lvm_vdo_get_stats (vg_name, pool_name)

lvm_vdo_get_stats_full (vg_name, pool_name)

lvm_vdo_info (vg_name, lv_name)

lvm_vdo_pool_convert (vg_name, pool_lv, name, virtual_size, index_memory, compression, deduplication, write_policy, extra)

lvm_vdo_pool_create (vg_name, lv_name, pool_name, data_size, virtual_size, index_memory, compression, deduplication, write_policy, extra)

lvm_vdo_pool_resize (vg_name, pool_name, size, extra)

lvm_vdo_resize (vg_name, lv_name, size, extra)

lvm_vdolvpoolname (vg_name, lv_name)

lvm_vgactivate (vg_name, extra)

lvm_vgcreate (name, pv_list, pe_size, extra)

lvm_vgdeactivate (vg_name, extra)

lvm_vgextend (vg_name, device, extra)

lvm_vginfo (vg_name)

lvm_vglock_start (vg_name, extra)

lvm_vglock_stop (vg_name, extra)

lvm_vgreduce (vg_name, device, extra)

lvm_vgremove (vg_name, extra)

lvm_vgrename (old_vg_name, new_vg_name, extra)

lvm_vgs ()

lvm_writecache_attach (vg_name, data_lv, cache_lv, extra)

lvm_writecache_create_cached_lv (vg_name, lv_name, data_size, cache_size, slow_pvs, fast_pvs)

lvm_writecache_detach (vg_name, cached_lv, destroy, extra)

md_activate (raid_spec, members, uuid, start_degraded, extra)

md_add (raid_spec, device, raid_devs, extra)

md_canonicalize_uuid (uuid)

md_create (device_name, level, disks, spares, version, bitmap, chunk_size, extra)

md_deactivate (raid_spec)

md_denominate (device)

md_destroy (device)

md_detail (raid_spec)

md_error_quark ()

md_examine (device)

md_get_bitmap_location (raid_spec)

md_get_md_uuid (uuid)

md_get_status (raid_spec)

md_get_superblock_size (member_size, version)

md_is_tech_avail (tech, mode)

md_name_from_node (node)

md_node_from_name (name)

md_nominate (device)

md_remove (raid_spec, device, fail, extra)

md_request_sync_action (raid_spec, action)

md_run (raid_spec)

md_set_bitmap_location (raid_spec, location)

mpath_error_quark ()

mpath_flush_mpaths ()

mpath_get_mpath_members ()

mpath_is_mpath_member (device)

mpath_is_tech_avail (tech, mode)

mpath_set_friendly_names (enabled)

nvdimm_error_quark ()

nvdimm_is_tech_avail (tech, mode)

nvdimm_list_namespaces (bus, region, idle, extra)

nvdimm_namespace_disable (namespace, extra)

nvdimm_namespace_enable (namespace, extra)

nvdimm_namespace_get_devname (device)

nvdimm_namespace_get_mode_from_str (mode_str)

nvdimm_namespace_get_mode_str (mode)

nvdimm_namespace_get_supported_sector_sizes (mode)

nvdimm_namespace_info (namespace, extra)

nvdimm_namespace_reconfigure (namespace, mode, force, extra)

nvme_connect (subsysnqn, transport, transport_addr, transport_svcid, host_traddr, host_iface, host_nqn, host_id, extra)

nvme_device_self_test (device, action)

nvme_disconnect (subsysnqn)

nvme_disconnect_by_path (path)

nvme_error_quark ()

nvme_find_ctrls_for_ns (ns_sysfs_path, subsysnqn, host_nqn, host_id)

nvme_format (device, lba_data_size, metadata_size, secure_erase)

nvme_generate_host_nqn ()

nvme_get_controller_info (device)

nvme_get_error_log_entries (device)

nvme_get_host_id ()

nvme_get_host_nqn ()

nvme_get_namespace_info (device)

nvme_get_sanitize_log (device)

nvme_get_self_test_log (device)

nvme_get_smart_log (device)

nvme_sanitize (device, action, no_dealloc, overwrite_pass_count, overwrite_pattern, overwrite_invert_pattern)

nvme_self_test_result_to_string (result)

nvme_set_host_id (host_id)

nvme_set_host_nqn (host_nqn)

part_create_part (disk, type, start, size, align)

part_create_table (disk, type, ignore_existing)

part_delete_part (disk, part)

part_error_quark ()

part_get_best_free_region (disk, type, size)

part_get_disk_free_regions (disk)

part_get_disk_parts (disk)

part_get_disk_spec (disk)

part_get_part_by_pos (disk, position)

part_get_part_spec (disk, part)

part_get_part_table_type_str (type)

part_get_type_str (type)

part_is_tech_avail (tech, mode)

part_resize_part (disk, part, size, align)

part_set_part_attributes (disk, part, attrs)

part_set_part_bootable (disk, part, bootable)

part_set_part_id (disk, part, part_id)

part_set_part_name (disk, part, name)

part_set_part_type (disk, part, type_guid)

part_set_part_uuid (disk, part, uuid)

reinit (require_plugins, reload, log_func)

swap_error_quark ()

swap_is_tech_avail (tech, mode)

swap_mkswap (device, label, uuid, extra)

swap_set_label (device, label)

swap_set_uuid (device, uuid)

swap_swapoff (device)

swap_swapon (device, priority)

swap_swapstatus (device)

try_init (request_plugins, log_func)

try_reinit (require_plugins, reload, log_func)

utils_check_linux_version (major, minor, micro)

utils_check_util_version (util, version, version_arg, version_regexp)

utils_dbus_service_available (connection, bus_type, bus_name, obj_prefix)

utils_echo_str_to_file (str, file_path)

utils_exec_and_capture_output (argv, extra)

utils_exec_and_report_error (argv, extra)

utils_exec_and_report_error_no_progress (argv, extra)

utils_exec_and_report_progress (argv, extra, prog_extract)

utils_exec_and_report_status_error (argv, extra)

utils_exec_with_input (argv, input, extra)

utils_get_device_symlinks (dev_spec)

utils_get_linux_version ()

utils_get_next_task_id ()

utils_have_kernel_module (module_name)

utils_init_logging (new_log_func)

utils_init_prog_reporting (new_prog_func)

utils_init_prog_reporting_thread (new_prog_func)

utils_load_kernel_module (module_name, options)

utils_log (level, msg)

utils_log_stdout (level, msg)

utils_log_task_status (task_id, msg)

utils_mute_prog_reporting_thread ()

utils_prog_reporting_initialized ()

utils_report_finished (task_id, msg)

utils_report_progress (task_id, completion, msg)

utils_report_started (msg)

utils_resolve_device (dev_spec)

utils_set_log_level (level)

utils_unload_kernel_module (module_name)

utils_version_cmp (ver_string1, ver_string2)

Details

BlockDev.btrfs_add_device(mountpoint, device, extra)
Parameters:
  • mountpoint (str) – mountpoint of the btrfs volume to add new device to

  • device (str) – a device to add to the btrfs volume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the addition (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.btrfs_change_label(mountpoint, label)
Parameters:
  • mountpoint (str) – a mountpoint of the btrfs filesystem to change label of

  • label (str) – new label for the filesystem

Raises:

GLib.Error

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:

bool

BlockDev.btrfs_check(device, extra)
Parameters:
  • device (str) – a device that is part of the checked btrfs volume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the check (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the filesystem was successfully checked or not

Tech category: BlockDev.BtrfsTech.FS-BlockDev.BtrfsTechMode.QUERY

Return type:

bool

BlockDev.btrfs_create_snapshot(source, dest, ro, extra)
Parameters:
  • source (str) – path to source subvolume

  • dest (str) – path to new snapshot volume

  • ro (bool) – whether the snapshot should be read-only

  • extra ([BlockDev.ExtraArg] or None) – extra options for the snapshot creation (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the dest snapshot of source was successfully created or not

Tech category: BlockDev.BtrfsTech.SNAPSHOT-BlockDev.BtrfsTechMode.CREATE

Return type:

bool

BlockDev.btrfs_create_subvolume(mountpoint, name, extra)
Parameters:
  • mountpoint (str) – mountpoint of the btrfs volume to create subvolume under

  • name (str) – name of the subvolume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the subvolume creation (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the mountpoint/name subvolume was successfully created or not

Tech category: BlockDev.BtrfsTech.SUBVOL-BlockDev.BtrfsTechMode.CREATE

Return type:

bool

BlockDev.btrfs_create_volume(devices, label, data_level, md_level, extra)
Parameters:
  • devices ([str]) – list of devices to create btrfs volume from

  • label (str or None) – label for the volume

  • data_level (str or None) – RAID level for the data or None to use the default

  • md_level (str or None) – RAID level for the metadata or None to use the default

  • extra ([BlockDev.ExtraArg] or None) – extra options for the volume creation (right now passed to the ‘mkfs.btrfs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.btrfs_delete_subvolume(mountpoint, name, extra)
Parameters:
  • mountpoint (str) – mountpoint of the btrfs volume to delete subvolume from

  • name (str) – name of the subvolume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the subvolume deletion (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the mountpoint/name subvolume was successfully deleted or not

Tech category: BlockDev.BtrfsTech.SUBVOL-BlockDev.BtrfsTechMode.DELETE

Return type:

bool

BlockDev.btrfs_error_quark()
Return type:

int

BlockDev.btrfs_filesystem_info(device)
Parameters:

device (str) – a device that is part of the queried btrfs volume

Raises:

GLib.Error

Returns:

information about the device's volume’s filesystem or None in case of error

Tech category: BlockDev.BtrfsTech.FS-BlockDev.BtrfsTechMode.QUERY

Return type:

BlockDev.BtrfsFilesystemInfo

BlockDev.btrfs_get_default_subvolume_id(mountpoint)
Parameters:

mountpoint (str) – mountpoint of the volume to get the default subvolume ID of

Raises:

GLib.Error

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:

int

BlockDev.btrfs_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.btrfs_list_devices(device)
Parameters:

device (str) – a device that is part of the queried btrfs volume

Raises:

GLib.Error

Returns:

information about the devices that are part of the btrfs volume containing device or None in case of error

Tech category: BlockDev.BtrfsTech.MULTI_DEV-BlockDev.BtrfsTechMode.QUERY

Return type:

[BlockDev.BtrfsDeviceInfo]

BlockDev.btrfs_list_subvolumes(mountpoint, snapshots_only)
Parameters:
  • mountpoint (str) – a mountpoint of the queried btrfs volume

  • snapshots_only (bool) – whether to list only snapshot subvolumes or not

Raises:

GLib.Error

Returns:

information about the subvolumes that are part of the btrfs volume mounted at mountpoint or None in case of error

The 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.BtrfsSubvolumeInfo]

BlockDev.btrfs_mkfs(devices, label, data_level, md_level, extra)
Parameters:
  • devices ([str]) – list of devices to create btrfs volume from

  • label (str or None) – label for the volume

  • data_level (str or None) – RAID level for the data or None to use the default

  • md_level (str or None) – RAID level for the metadata or None to use the default

  • extra ([BlockDev.ExtraArg] or None) – extra options for the volume creation (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.btrfs_remove_device(mountpoint, device, extra)
Parameters:
  • mountpoint (str) – mountpoint of the btrfs volume to remove device from

  • device (str) – a device to remove from the btrfs volume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the removal (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.btrfs_repair(device, extra)
Parameters:
  • device (str) – a device that is part of the to be repaired btrfs volume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the filesystem was successfully checked and repaired or not

Tech category: BlockDev.BtrfsTech.FS-BlockDev.BtrfsTechMode.MODIFY

Return type:

bool

BlockDev.btrfs_resize(mountpoint, size, extra)
Parameters:
  • mountpoint (str) – a mountpoint of the to be resized btrfs filesystem

  • size (int) – requested new size

  • extra ([BlockDev.ExtraArg] or None) – extra options for the volume resize (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the mountpoint filesystem was successfully resized to size or not

Tech category: BlockDev.BtrfsTech.FS-BlockDev.BtrfsTechMode.MODIFY

Return type:

bool

BlockDev.btrfs_set_default_subvolume(mountpoint, subvol_id, extra)
Parameters:
  • mountpoint (str) – mountpoint of the volume to set the default subvolume ID of

  • subvol_id (int) – ID of the subvolume to be set as the default subvolume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the setting (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.crypto_bitlk_close(bitlk_device)
Parameters:

bitlk_device (str) – BITLK device to close

Raises:

GLib.Error

Returns:

whether the given bitlk_device was successfully closed or not

Tech category: BlockDev.CryptoTech.BITLK-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

BlockDev.crypto_bitlk_info(device)
Parameters:

device (str) – a device to get information about

Raises:

GLib.Error

Return type:

BlockDev.CryptoBITLKInfo

Returns (transfer full): information about the device or None in case of error

Tech category: BlockDev.CryptoTech.BITLK-BlockDev.CryptoTechMode.QUERY

BlockDev.crypto_bitlk_open(device, name, context, read_only)
Parameters:
  • device (str) – the device to open

  • name (str) – name for the BITLK device

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) for this BITLK device

  • read_only (bool) – whether to open as read-only or not (meaning read-write)

Raises:

GLib.Error

Returns:

whether the device was successfully opened or not

Tech category: BlockDev.CryptoTech.BITLK-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

Supported context types for this function: BlockDev.passphrase, key file

BlockDev.crypto_device_is_luks(device)
Parameters:

device (str) – the queried device

Raises:

GLib.Error

Returns:

True if the given device is a LUKS device or False 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:

bool

BlockDev.crypto_device_seems_encrypted(device)
Parameters:

device (str) – the queried device

Raises:

GLib.Error

Returns:

True if the given device seems to be encrypted or False 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:

bool

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_error_quark()
Return type:

int

BlockDev.crypto_escrow_device(device, passphrase, cert_data, directory, backup_passphrase)
Parameters:
  • device (str) – path of the device to create escrow data for

  • passphrase (str) – BlockDev.passphrase used for the device

  • cert_data ([int]) – certificate data to use for escrow

  • directory (str) – directory to put escrow data into

  • backup_passphrase (str or None) – backup BlockDev.passphrase for the device or None

Raises:

GLib.Error

Returns:

whether the escrow data was successfully created for device or not

Tech category: BlockDev.CryptoTech.ESCROW-BlockDev.CryptoTechMode.CREATE

Return type:

bool

BlockDev.crypto_fvault2_close(fvault2_device)
Parameters:

fvault2_device (str) – FVAULT2 device to close

Raises:

GLib.Error

Returns:

whether the given fvault2_device was successfully closed or not

Tech category: BlockDev.CryptoTech.FVAULT2-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

BlockDev.crypto_fvault2_open(device, name, context, read_only)
Parameters:
  • device (str) – the device to open

  • name (str) – name for the FVAULT2 device

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) for this FVAULT2 volume

  • read_only (bool) – whether to open as read-only or not (meaning read-write)

Raises:

GLib.Error

Returns:

whether the device was successfully opened or not

Tech category: BlockDev.CryptoTech.FVAULT2-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

Supported context types for this function: BlockDev.passphrase, key file

BlockDev.crypto_generate_backup_passphrase()
Raises:

GLib.Error

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:

str

BlockDev.crypto_integrity_close(integrity_device)
Parameters:

integrity_device (str) – integrity device to close

Raises:

GLib.Error

Returns:

whether the given integrity_device was successfully closed or not

Tech category: BlockDev.CryptoTech.INTEGRITY-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

BlockDev.crypto_integrity_format(device, algorithm, wipe, context, extra)
Parameters:
  • device (str) – a device to format as integrity

  • algorithm (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 checksums

  • context (BlockDev.CryptoKeyslotContext or None) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) for this device

  • extra (BlockDev.CryptoIntegrityExtra or None) – extra arguments for integrity format creation

Raises:

GLib.Error

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:

bool

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:

GLib.Error

Returns:

information about the device or None in case of error

Tech category: BlockDev.CryptoTech.INTEGRITY-BlockDev.CryptoTechMode.QUERY

Return type:

BlockDev.CryptoIntegrityInfo

BlockDev.crypto_integrity_open(device, name, algorithm, context, flags, extra)
Parameters:
Raises:

GLib.Error

Returns:

whether the device was successfully opened or not

Tech category: BlockDev.CryptoTech.INTEGRITY-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

Supported context types for this function: volume key

BlockDev.crypto_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.crypto_keyring_add_key(key_desc, key_data)
Parameters:
  • key_desc (str) – kernel BlockDev.keyring key description

  • key_data (bytes) – a key to add to kernel BlockDev.keyring (may contain arbitrary binary data)

Raises:

GLib.Error

Returns:

whether the given key was successfully saved to kernel BlockDev.keyring or not

Tech category: BlockDev.CryptoTech.KEYRING-BlockDev.CryptoTechMode.ADD_KEY

Return type:

bool

BlockDev.crypto_luks_add_key(device, context, ncontext)
Parameters:
  • device (str) – device to add new key to

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) to for this LUKS device

  • ncontext (BlockDev.CryptoKeyslotContext) – new key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) to add to this LUKS device

Raises:

GLib.Error

Returns:

whether the ncontext was successfully added to device or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.ADD_KEY

Return type:

bool

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 of

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) for this LUKS device

  • ncontext (BlockDev.CryptoKeyslotContext) – new key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) to add to this LUKS device

Raises:

GLib.Error

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:

bool

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:

GLib.Error

Returns:

whether the given luks_device was successfully closed or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

BlockDev.crypto_luks_format(device, cipher, key_size, context, min_entropy, luks_version, extra)
Parameters:
  • device (str) – a device to format as LUKS

  • cipher (str or None) – cipher specification (type-mode, e.g. “aes-xts-plain64”) or None to use the default

  • key_size (int) – size of the volume key in bits or 0 to use the default

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) for this LUKS device

  • min_entropy (int) – minimum random data entropy (in bits) required to format device as LUKS

  • luks_version (BlockDev.CryptoLUKSVersion) – whether to use LUKS v1 or LUKS v2

  • extra (BlockDev.CryptoLUKSExtra or None) – extra arguments for LUKS format creation

Raises:

GLib.Error

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:

bool

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:
  • device (str) – device to backup the LUKS header

  • backup_file (str) – file to save the header backup to

Raises:

GLib.Error

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:

bool

BlockDev.crypto_luks_header_restore(device, backup_file)
Parameters:
  • device (str) – device to restore the LUKS header to

  • backup_file (str) – existing file with a LUKS header backup

Raises:

GLib.Error

Returns:

whether the given device LUKS header was successfully restored from backup_file

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.BACKUP_RESTORE

Return type:

bool

BlockDev.crypto_luks_info(device)
Parameters:

device (str) – a device to get information about

Raises:

GLib.Error

Returns:

information about the device or None in case of error

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.QUERY

Return type:

BlockDev.CryptoLUKSInfo

BlockDev.crypto_luks_kill_slot(device, slot)
Parameters:
  • device (str) – device to kill slot on

  • slot (int) – keyslot to destroy

Raises:

GLib.Error

Returns:

whether the given slot was successfully destroyed or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.REMOVE_KEY

Return type:

bool

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 open

  • name (str) – name for the LUKS device

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) to open this LUKS device

  • read_only (bool) – whether to open as read-only or not (meaning read-write)

Raises:

GLib.Error

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 with BlockDev.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:

bool

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 to

  • context (BlockDev.CryptoKeyslotContext) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) to remove from this LUKS device

Raises:

GLib.Error

Returns:

whether the key was successfully removed or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.REMOVE_KEY

Return type:

bool

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 resize

  • size (int) – requested size in sectors or 0 to adapt to the backing device

  • context (BlockDev.CryptoKeyslotContext or None) – key slot context (BlockDev.passphrase/BlockDev.keyfile/token…) for this LUKS device

Raises:

GLib.Error

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:

bool

Supported context types for this function: BlockDev.passphrase, key file

BlockDev.crypto_luks_resume(luks_device, context)
Parameters:
Raises:

GLib.Error

Returns:

whether the given luks_device was successfully resumed or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.SUSPEND_RESUME

Return type:

bool

Supported context types for this function: BlockDev.passphrase, key file

BlockDev.crypto_luks_set_label(device, label, subsystem)
Parameters:
  • device (str) – device to set label on

  • label (str or None) – label to set

  • subsystem (str or None) – subsystem to set

Raises:

GLib.Error

Returns:

whether the given label and subsystem were successfully set or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.MODIFY

Return type:

bool

BlockDev.crypto_luks_set_uuid(device, uuid)
Parameters:
  • device (str) – device to set UUID on

  • uuid (str or None) – UUID to set or None to generate a new one

Raises:

GLib.Error

Returns:

whether the given uuid was successfully set or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.MODIFY

Return type:

bool

BlockDev.crypto_luks_status(luks_device)
Parameters:

luks_device (str) – the queried LUKS device

Raises:

GLib.Error

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:

str

BlockDev.crypto_luks_suspend(luks_device)
Parameters:

luks_device (str) – LUKS device to suspend

Raises:

GLib.Error

Returns:

whether the given luks_device was successfully suspended or not

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.SUSPEND_RESUME

Return type:

bool

BlockDev.crypto_luks_token_info(device)
Parameters:

device (str) – a device to get LUKS2 token information about

Raises:

GLib.Error

Returns:

information about tokens on device

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.QUERY

Return type:

[BlockDev.CryptoLUKSTokenInfo]

BlockDev.crypto_tc_close(tc_device)
Parameters:

tc_device (str) – TrueCrypt/VeraCrypt device to close

Raises:

GLib.Error

Returns:

whether the given tc_device was successfully closed or not

Tech category: BlockDev.CryptoTech.TRUECRYPT-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

BlockDev.crypto_tc_open(device, name, context, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only)
Parameters:
  • device (str) – the device to open

  • name (str) – name for the TrueCrypt/VeraCrypt device

  • context (BlockDev.CryptoKeyslotContext or None) – BlockDev.passphrase key slot context for this TrueCrypt/VeraCrypt volume

  • keyfiles ([str] or None) – paths to the keyfiles for the TrueCrypt/VeraCrypt volume

  • hidden (bool) – whether a hidden volume inside the volume should be opened

  • system (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 is True)

  • read_only (bool) – whether to open as read-only or not (meaning read-write)

Raises:

GLib.Error

Returns:

whether the device was successfully opened or not

Tech category: BlockDev.CryptoTech.TRUECRYPT-BlockDev.CryptoTechMode.OPEN_CLOSE

Return type:

bool

Supported context types for this function: BlockDev.passphrase

BlockDev.dm_create_linear(map_name, device, length, uuid)
Parameters:
  • map_name (str) – name of the map

  • device (str) – device to create map for

  • length (int) – length of the mapping in sectors

  • uuid (str or None) – UUID for the new dev mapper device or None if not specified

Raises:

GLib.Error

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:

bool

BlockDev.dm_error_quark()
Return type:

int

BlockDev.dm_get_subsystem_from_name(device_name)
Parameters:

device_name (str) – name of the device

Raises:

GLib.Error

Returns:

subsystem of the given device

Tech category: BlockDev.DMTech.DM_TECH_MAP-BlockDev.DMTechMode.QUERY

Return type:

str

BlockDev.dm_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.dm_map_exists(map_name, live_only, active_only)
Parameters:
  • map_name (str) – name of the queried map

  • live_only (bool) – whether to go through the live maps only or not

  • active_only (bool) – whether to ignore suspended maps or not

Raises:

GLib.Error

Returns:

whether the given map_name exists (and is live if live_only is True (and is active if active_only is True)).

Tech category: BlockDev.DMTech.DM_TECH_MAP-BlockDev.DMTechMode.QUERY

Return type:

bool

BlockDev.dm_name_from_node(dm_node)
Parameters:

dm_node (str) – name of the DM node (e.g. “dm-0”)

Raises:

GLib.Error

Returns:

map name of the map providing the dm_node device or None (error) contains the error in such cases

Tech category: BlockDev.DMTech.DM_TECH_MAP-BlockDev.DMTechMode.QUERY

Return type:

str

BlockDev.dm_node_from_name(map_name)
Parameters:

map_name (str) – name of the queried DM map

Raises:

GLib.Error

Returns:

DM node name for the map_name map or None (error) contains the error in such cases

Tech category: BlockDev.DMTech.DM_TECH_MAP-BlockDev.DMTechMode.QUERY

Return type:

str

BlockDev.dm_remove(map_name)
Parameters:

map_name (str) – name of the map to remove

Raises:

GLib.Error

Returns:

whether the map_name map was successfully removed or not

Tech category: BlockDev.DMTech.DM_TECH_MAP-BlockDev.DMTechMode.REMOVE_DEACTIVATE

Return type:

bool

BlockDev.ensure_init(require_plugins, log_func)
Parameters:
Raises:

GLib.Error

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:

bool

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] or None) – A list of BlockDev.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 check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the check (right now passed to the ‘btrfsck’ utility)

Raises:

GLib.Error

Returns:

whether the filesystem was successfully checked or not

Tech category: BlockDev.FSTech.BTRFS-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_btrfs_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_btrfs_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_btrfs_get_info(mpoint)
Parameters:

mpoint (str) – a mountpoint of the btrfs filesystem to get information about

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Note: 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.FSBtrfsInfo

BlockDev.fs_btrfs_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new btrfs fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkfs.btrfs’ utility)

Raises:

GLib.Error

Returns:

whether a new btrfs fs was successfully created on device or not

Tech category: BlockDev.FSTech.BTRFS-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_btrfs_repair(device, extra)
Parameters:
  • device (str) – the device containing the file system to repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

Returns:

whether the filesystem was successfully checked and repaired or not

Tech category: BlockDev.FSTech.BTRFS-BlockDev.FSTechMode.REPAIR

Return type:

bool

BlockDev.fs_btrfs_resize(mpoint, new_size, extra)
Parameters:
  • mpoint (str) – a mountpoint of the to be resized btrfs filesystem

  • new_size (int) – requested new size

  • extra ([BlockDev.ExtraArg] or None) – extra options for the volume resize (right now passed to the ‘btrfs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_btrfs_set_label(mpoint, label)
Parameters:
  • mpoint (str) – the mount point of the file system to resize

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_btrfs_set_uuid(device, uuid)
Parameters:
  • device (str) – the device containing the file system to set the UUID (serial number) for

  • uuid (str or None) – UUID to set or None to generate a new one

Raises:

GLib.Error

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:

bool

BlockDev.fs_can_check(type)
Parameters:

type (str) – the filesystem type to be tested for installed consistency check support

Raises:

GLib.Error

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:

(bool, required_utility: str)

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:

GLib.Error

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:

(bool, required_utility: str)

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_size(type)
Parameters:

type (str) – the filesystem type to be tested for installed size querying support

Raises:

GLib.Error

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:

(bool, required_utility: str)

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:

GLib.Error

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:

GLib.Error

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:

(bool, required_utility: str)

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:

GLib.Error

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:

GLib.Error

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:

(bool, required_utility: str)

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:

GLib.Error

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:

(bool, required_utility: str)

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:
  • device (str) – the device the file system of which to check

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

Returns:

whether the file system on device passed the consistency check or not

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.CHECK

Return type:

bool

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:
  • fstype (str) – the filesystem type to check label for

  • label (str) – label to check

Raises:

GLib.Error

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:

bool

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:
  • fstype (str) – the filesystem type to check uuid for

  • uuid (str) – uuid to check

Raises:

GLib.Error

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:

bool

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:
  • device (str) – the device to clean

  • force (bool) – whether to wipe signatures on a mounted device

Raises:

GLib.Error

Returns:

whether device was successfully cleaned or not

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.WIPE

Return type:

bool

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_error_quark()
Return type:

int

BlockDev.fs_exfat_check(device, extra)
Parameters:
  • device (str) – the device containing the file system to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘exfatfsck’ utility)

Raises:

GLib.Error

Returns:

whether the exfat file system on the device is clean or not

Tech category: BlockDev.FSTech.EXFAT-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_exfat_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_exfat_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_exfat_get_info(device)
Parameters:

device (str) – the device containing the file system to get info for

Raises:

GLib.Error

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.FSExfatInfo

BlockDev.fs_exfat_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new exfat fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkexfatfs’ utility)

Raises:

GLib.Error

Returns:

whether a new exfat fs was successfully created on device or not

Tech category: BlockDev.FSTech.EXFAT-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_exfat_repair(device, extra)
Parameters:
  • device (str) – the device containing the file system to repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘exfatfsck’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_exfat_set_label(device, label)
Parameters:
  • device (str) – the device containing the file system to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_exfat_set_uuid(device, uuid)
Parameters:
  • device (str) – the device containing the file system to set uuid for

  • uuid (str or None) – volume ID to set or None to generate a new one

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext2_check(device, extra)
Parameters:
  • device (str) – the device the file system on which to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the check (right now passed to the ‘e2fsck’ utility)

Raises:

GLib.Error

Returns:

whether an ext2 file system on the device is clean or not

Tech category: BlockDev.FSTech.EXT2-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_ext2_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext2_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext2_get_info(device)
Parameters:

device (str) – the device the file system of which to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.EXT2-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSExt2Info

BlockDev.fs_ext2_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new ext2 fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mke2fs’ utility)

Raises:

GLib.Error

Returns:

whether a new ext2 fs was successfully created on device or not

Tech category: BlockDev.FSTech.EXT2-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_ext2_repair(device, unsafe, extra)
Parameters:
  • device (str) – the device the file system on which to repair

  • unsafe (bool) – whether to do unsafe operations too

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘e2fsck’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext2_resize(device, new_size, extra)
Parameters:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the resize (right now passed to the ‘resize2fs’ utility)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.EXT2-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_ext2_set_label(device, label)
Parameters:
  • device (str) – the device the file system on which to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext2_set_uuid(device, uuid)
Parameters:
  • device (str) – the device the file system on which to set UUID for

  • uuid (str or None) – UUID to set None to generate a new one UUID can also be one of “clear”, “random” and “time” to clear, generate a new random/time-based UUID

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext3_check(device, extra)
Parameters:
  • device (str) – the device the file system on which to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the check (right now passed to the ‘e2fsck’ utility)

Raises:

GLib.Error

Returns:

whether an ext3 file system on the device is clean or not

Tech category: BlockDev.FSTech.EXT3-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_ext3_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext3_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext3_get_info(device)
Parameters:

device (str) – the device the file system of which to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.EXT3-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSExt3Info

BlockDev.fs_ext3_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new ext3 fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mke2fs’ utility)

Raises:

GLib.Error

Returns:

whether a new ext3 fs was successfully created on device or not

Tech category: BlockDev.FSTech.EXT3-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_ext3_repair(device, unsafe, extra)
Parameters:
  • device (str) – the device the file system on which to repair

  • unsafe (bool) – whether to do unsafe operations too

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘e2fsck’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext3_resize(device, new_size, extra)
Parameters:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the resize (right now passed to the ‘resize2fs’ utility)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.EXT3-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_ext3_set_label(device, label)
Parameters:
  • device (str) – the device the file system on which to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext3_set_uuid(device, uuid)
Parameters:
  • device (str) – the device the file system on which to set UUID for

  • uuid (str or None) – UUID to set None to generate a new one UUID can also be one of “clear”, “random” and “time” to clear, generate a new random/time-based UUID

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext4_check(device, extra)
Parameters:
  • device (str) – the device the file system on which to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the check (right now passed to the ‘e2fsck’ utility)

Raises:

GLib.Error

Returns:

whether an ext4 file system on the device is clean or not

Tech category: BlockDev.FSTech.EXT4-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_ext4_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext4_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext4_get_info(device)
Parameters:

device (str) – the device the file system of which to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.EXT3-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSExt4Info

BlockDev.fs_ext4_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new ext4 fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkfs.ext4’ utility)

Raises:

GLib.Error

Returns:

whether a new ext4 fs was successfully created on device or not

Tech category: BlockDev.FSTech.EXT4-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_ext4_repair(device, unsafe, extra)
Parameters:
  • device (str) – the device the file system on which to repair

  • unsafe (bool) – whether to do unsafe operations too

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘e2fsck’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext4_resize(device, new_size, extra)
Parameters:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the resize (right now passed to the ‘resize2fs’ utility)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.EXT4-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_ext4_set_label(device, label)
Parameters:
  • device (str) – the device the file system on which to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_ext4_set_uuid(device, uuid)
Parameters:
  • device (str) – the device the file system on which to set UUID for

  • uuid (str or None) – UUID to set None to generate a new one UUID can also be one of “clear”, “random” and “time” to clear, generate a new random/time-based UUID

Raises:

GLib.Error

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:

bool

BlockDev.fs_f2fs_check(device, extra)
Parameters:
  • device (str) – the device containing the file system to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘fsck.f2fs’ utility)

Raises:

GLib.Error

Returns:

whether an f2fs file system on the device is clean or not

Tech category: BlockDev.FSTech.F2FS-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_f2fs_get_info(device)
Parameters:

device (str) – the device containing the file system to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.F2FS-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSF2FSInfo

BlockDev.fs_f2fs_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new f2fs fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkfs.f2fs’ utility)

Raises:

GLib.Error

Returns:

whether a new f2fs fs was successfully created on device or not

Tech category: BlockDev.FSTech.F2FS-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_f2fs_repair(device, extra)
Parameters:
  • device (str) – the device containing the file system to repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘fsck.f2fs’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_f2fs_resize(device, new_size, safe, extra)
Parameters:
  • device (str) – the device containing the file system to resize

  • new_size (int) – new requested size for the file system *in file system sectors* (see BlockDev.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] or None) – extra options for the resize (right now passed to the ‘resize.f2fs’ utility)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.F2FS-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_features(fstype)
Parameters:

fstype (str) – name of the filesystem to get features for (e.g. “ext4”)

Raises:

GLib.Error

Return type:

BlockDev.FSFeatures

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:

GLib.Error

Returns:

whether mountpoint was successfully freezed or not

Return type:

bool

Freezes filesystem mounted on mountpoint. The filesystem must support freezing.

BlockDev.fs_get_free_space(device, fstype)
Parameters:
  • device (str) – the device with file system to get free space for

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

Returns:

free space of filesystem on device, 0 in case of error.

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.QUERY

Return type:

int

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:

GLib.Error

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:

str

Get first signature on device as a string.

BlockDev.fs_get_mountpoint(device)
Parameters:

device (str) – device to find mountpoint for

Raises:

GLib.Error

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:

str

Get mountpoint for device. If device is mounted multiple times only one mountpoint will be returned.

BlockDev.fs_get_size(device, fstype)
Parameters:
  • device (str) – the device with file system to get size for

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

Returns:

size of filesystem on device, 0 in case of error.

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.QUERY

Return type:

int

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.

BlockDev.fs_is_mountpoint(path)
Parameters:

path (str) – path (folder) to check

Raises:

GLib.Error

Returns:

whether path is a mountpoint or not

Tech category: BlockDev.FSTech.MOUNT (no mode, ignored)

Return type:

bool

BlockDev.fs_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.fs_mkfs(device, fstype, options, extra)
Parameters:
  • device (str) – the device to create the new filesystem on

  • fstype (str) – name of the filesystem to create (e.g. “ext4”)

  • options (BlockDev.FSMkfsOptions) – additional options like label or UUID for the filesystem

  • extra ([BlockDev.ExtraArg] or None) – extra mkfs options not provided in options

Raises:

GLib.Error

Returns:

whether fstype was successfully created on device or not.

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.MKFS

Return type:

bool

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 (see BlockDev.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 or None) – device to mount, if not specified mountpoint entry from fstab will be used

  • mountpoint (str or None) – mountpoint for device, if not specified device entry from fstab will be used

  • fstype (str or None) – filesystem type

  • options (str or None) – comma delimited options for mount

  • extra ([BlockDev.ExtraArg] or None) – 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:

GLib.Error

Returns:

whether device (or mountpoint) was successfully mounted or not

Tech category: BlockDev.FSTech.MOUNT (no mode, ignored)

Return type:

bool

BlockDev.fs_nilfs2_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_nilfs2_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_nilfs2_get_info(device)
Parameters:

device (str) – the device containing the file system to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.NILFS2-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSNILFS2Info

BlockDev.fs_nilfs2_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new nilfs fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkfs.nilfs2’ utility)

Raises:

GLib.Error

Returns:

whether a new nilfs fs was successfully created on device or not

Tech category: BlockDev.FSTech.NILFS2-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_nilfs2_resize(device, new_size)
Parameters:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.NILFS2-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_nilfs2_set_label(device, label)
Parameters:
  • device (str) – the device containing the file system to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_nilfs2_set_uuid(device, uuid)
Parameters:
  • device (str) – the device containing the file system to set UUID for

  • uuid (str or None) – UUID to set or None to generate a new one

Raises:

GLib.Error

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:

bool

BlockDev.fs_ntfs_check(device, extra)
Parameters:
  • device (str) – the device containing the file system to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘ntfsfix’ utility)

Raises:

GLib.Error

Returns:

whether an ntfs file system on the device is clean or not

Tech category: BlockDev.FSTech.NTFS-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_ntfs_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_ntfs_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

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:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.NTFS-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSNtfsInfo

BlockDev.fs_ntfs_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new ntfs fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkntfs’ utility)

Raises:

GLib.Error

Returns:

whether a new NTFS fs was successfully created on device or not

Tech category: BlockDev.FSTech.NTFS-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_ntfs_repair(device, extra)
Parameters:
  • device (str) – the device containing the file system to repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘ntfsfix’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_ntfs_resize(device, new_size)
Parameters:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system in bytes (if 0, the file system is adapted to the underlying block device)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.NTFS-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_ntfs_set_label(device, label)
Parameters:
  • device (str) – the device containing the file system to set the label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_ntfs_set_uuid(device, uuid)
Parameters:
  • device (str) – the device containing the file system to set the UUID (serial number) for

  • uuid (str or None) – UUID to set or None to generate a new one

Raises:

GLib.Error

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:

bool

BlockDev.fs_repair(device, fstype)
Parameters:
  • device (str) – the device the file system of which to repair

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

Returns:

whether the file system on device was successfully repaired or not

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.REPAIR

Return type:

bool

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:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.RESIZE

Return type:

bool

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.

BlockDev.fs_set_label(device, label, fstype)
Parameters:
  • device (str) – the device with file system to set the label for

  • label (str) – label to set

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

Returns:

whether the file system on device was successfully relabeled or not

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.SET_LABEL

Return type:

bool

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.

BlockDev.fs_set_uuid(device, uuid, fstype)
Parameters:
  • device (str) – the device with file system to set the UUID for

  • uuid (str or None) – UUID to set or None to generate a new one

  • fstype (str or None) – the filesystem type on device or None to detect

Raises:

GLib.Error

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:

bool

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:

GLib.Error

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:

GLib.Error

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:

bool

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:

GLib.Error

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:

bool

BlockDev.fs_udf_get_info(device)
Parameters:

device (str) – the device containing the file system to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.UDF-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSUdfInfo

BlockDev.fs_udf_mkfs(device, media_type, revision, block_size, extra)
Parameters:
  • device (str) – the device to create a new UDF fs on

  • media_type (str or None) – specify the media type or None for default (‘hd’)

  • revision (str or None) – UDF revision to use or None for default (‘2.01’)

  • block_size (int) – block size in bytes or 0 for auto detection (device logical block size)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkudffs’ utility)

Raises:

GLib.Error

Returns:

whether a new UDF fs was successfully created on device or not

Tech category: BlockDev.FSTech.UDF-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_udf_set_label(device, label)
Parameters:
  • device (str) – the device containing the file system to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

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:
  • device (str) – the device containing the file system to set the UUID (serial number) for

  • uuid (str or None) – UUID to set or None to generate a new one

Raises:

GLib.Error

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:

bool

BlockDev.fs_unfreeze(mountpoint)
Parameters:

mountpoint (str) – mountpoint of the device (filesystem) to un-freeze

Raises:

GLib.Error

Returns:

whether mountpoint was successfully unfreezed or not

Return type:

bool

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 unmount

  • lazy (bool) – enable/disable lazy unmount

  • force (bool) – enable/disable force unmount

  • extra ([BlockDev.ExtraArg] or None) – 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:

GLib.Error

Returns:

whether spec was successfully unmounted or not

Tech category: BlockDev.FSTech.MOUNT (no mode, ignored)

Return type:

bool

BlockDev.fs_vfat_check(device, extra)
Parameters:
  • device (str) – the device containing the file system to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘fsck.vfat’ utility)

Raises:

GLib.Error

Returns:

whether an vfat file system on the device is clean or not

Tech category: BlockDev.FSTech.VFAT-BlockDev.FSTechMode.CHECK

Return type:

bool

BlockDev.fs_vfat_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_vfat_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_vfat_get_info(device)
Parameters:

device (str) – the device containing the file system to get info for

Raises:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.VFAT-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSVfatInfo

BlockDev.fs_vfat_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new vfat fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkfs.vfat’ utility)

Raises:

GLib.Error

Returns:

whether a new vfat fs was successfully created on device or not

Tech category: BlockDev.FSTech.VFAT-BlockDev.FSTechMode.MKFS

Return type:

bool

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 repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘fsck.vfat’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_vfat_resize(device, new_size)
Parameters:
  • device (str) – the device the file system of which to resize

  • new_size (int) – new requested size for the file system (if 0, the file system is adapted to the underlying block device)

Raises:

GLib.Error

Returns:

whether the file system on device was successfully resized or not

Tech category: BlockDev.FSTech.VFAT-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_vfat_set_label(device, label)
Parameters:
  • device (str) – the device containing the file system to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_vfat_set_uuid(device, uuid)
Parameters:
  • device (str) – the device containing the file system to set uuid for

  • uuid (str or None) – volume ID to set or None to generate a new one

Raises:

GLib.Error

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:

bool

BlockDev.fs_wipe(device, all, force)
Parameters:
  • device (str) – the device to wipe signatures from

  • all (bool) – whether to wipe all (True) signatures or just the first (False) one

  • force (bool) – whether to wipe signatures on a mounted device

Raises:

GLib.Error

Returns:

whether signatures were successfully wiped on device or not

Tech category: BlockDev.FSTech.GENERIC-BlockDev.FSTechMode.WIPE

Return type:

bool

BlockDev.fs_xfs_check(device, extra)
Parameters:
  • device (str) – the device containing the file system to check

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘xfs_repair’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_xfs_check_label(label)
Parameters:

label (str) – label to check

Raises:

GLib.Error

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:

bool

BlockDev.fs_xfs_check_uuid(uuid)
Parameters:

uuid (str) – UUID to check

Raises:

GLib.Error

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:

bool

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:

GLib.Error

Returns:

information about the file system on device or None in case of error

Tech category: BlockDev.FSTech.XFS-BlockDev.FSTechMode.QUERY

Return type:

BlockDev.FSXfsInfo

BlockDev.fs_xfs_mkfs(device, extra)
Parameters:
  • device (str) – the device to create a new xfs fs on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkfs.xfs’ utility)

Raises:

GLib.Error

Returns:

whether a new xfs fs was successfully created on device or not

Tech category: BlockDev.FSTech.XFS-BlockDev.FSTechMode.MKFS

Return type:

bool

BlockDev.fs_xfs_repair(device, extra)
Parameters:
  • device (str) – the device containing the file system to repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the repair (right now passed to the ‘xfs_repair’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.fs_xfs_resize(mpoint, new_size, extra)
Parameters:
  • mpoint (str) – the mount point of the file system to resize

  • new_size (int) – new requested size for the file system *in file system blocks* (see BlockDev.fs_xfs_get_info()) (if 0, the file system is adapted to the underlying block device)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the resize (right now passed to the ‘xfs_growfs’ utility)

Raises:

GLib.Error

Returns:

whether the file system mounted on mpoint was successfully resized or not

Tech category: BlockDev.FSTech.XFS-BlockDev.FSTechMode.RESIZE

Return type:

bool

BlockDev.fs_xfs_set_label(device, label)
Parameters:
  • device (str) – the device containing the file system to set label for

  • label (str) – label to set

Raises:

GLib.Error

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:

bool

BlockDev.fs_xfs_set_uuid(device, uuid)
Parameters:
  • device (str) – the device containing the file system to set uuid for

  • uuid (str or None) – UUID to set None to generate a new one UUID can also be one of “nil” and “generate” to clear or generate a new UUID

Raises:

GLib.Error

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:

bool

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:

str

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:

str

BlockDev.init(require_plugins, log_func)
Parameters:
Raises:

GLib.Error

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:

bool

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:

bool

BlockDev.is_plugin_available(plugin)
Parameters:

plugin (BlockDev.Plugin) – the queried plugin

Returns:

whether the given plugin is available or not

Return type:

bool

BlockDev.loop_error_quark()
Return type:

int

BlockDev.loop_get_loop_name(file)
Parameters:

file (str) – path of the backing file to get loop name for

Raises:

GLib.Error

Returns:

name of the loop device associated with the given file

Tech category: BlockDev.LoopTech.LOOP_TECH_LOOP-BlockDev.LoopTechMode.QUERY

Return type:

str

BlockDev.loop_info(loop)
Parameters:

loop (str) – name of the loop device to get information about (e.g. “loop0”)

Raises:

GLib.Error

Returns:

information about the loop device or None in case of error

Tech category: BlockDev.LoopTech.LOOP_TECH_LOOP-BlockDev.LoopTechMode.QUERY

Return type:

BlockDev.LoopInfo

BlockDev.loop_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.loop_set_autoclear(loop, autoclear)
Parameters:
  • loop (str) – path or name of the loop device

  • autoclear (bool) – whether to set or unset the autoclear flag

Raises:

GLib.Error

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:

bool

BlockDev.loop_setup(file, offset, size, read_only, part_scan, sector_size)
Parameters:
  • file (str) – file to setup as a loop device

  • offset (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 not

  • sector_size (int) – logical sector size for the loop device in bytes (or 0 for default)

Raises:

GLib.Error

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:

(bool, loop_name: str)

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 device

  • offset (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 not

  • sector_size (int) – logical sector size for the loop device in bytes (or 0 for default)

Raises:

GLib.Error

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:

(bool, loop_name: str)

BlockDev.loop_teardown(loop)
Parameters:

loop (str) – path or name of the loop device to tear down

Raises:

GLib.Error

Returns:

whether the loop device was successfully torn down or not

Tech category: BlockDev.LoopTech.LOOP_TECH_LOOP-BlockDev.LoopTechMode.DESTROY

Return type:

bool

BlockDev.lvm_add_lv_tags(vg_name, lv_name, tags)
Parameters:
  • vg_name (str) – name of the VG that contains the LV to set tags on

  • lv_name (str) – name of the LV to set tags on

  • tags ([str]) – list of tags to add

Raises:

GLib.Error

Returns:

whether the tags were successfully added to device or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

bool

BlockDev.lvm_add_pv_tags(device, tags)
Parameters:
  • device (str) – the device to set PV tags for

  • tags ([str]) – list of tags to add

Raises:

GLib.Error

Returns:

whether the tags were successfully added to device or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

bool

BlockDev.lvm_add_vg_tags(vg_name, tags)
Parameters:
  • vg_name (str) – the VG to set tags on

  • tags ([str]) – list of tags to add

Raises:

GLib.Error

Returns:

whether the tags were successfully added to vg_name or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

bool

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 LVs

  • data_lv (str) – data LV to attach the cache_pool_lv to

  • cache_pool_lv (str) – cache pool LV to attach to the data_lv

  • extra ([BlockDev.ExtraArg] or None) – extra options for the cache attachment (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

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 in

  • lv_name (str) – name of the cached LV to create

  • data_size (int) – size of the data LV

  • cache_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 default

  • mode (BlockDev.LVMCacheMode) – cache mode for the cached LV

  • flags (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:

GLib.Error

Returns:

whether the cached LV lv_name was successfully created or not

Tech category: BlockDev.LVMTech.CACHE-BlockDev.LVMTechMode.CREATE

Return type:

bool

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 in

  • pool_name (str) – name of the cache pool LV to create

  • pool_size (int) – desired size of the cache pool pool_name

  • md_size (int) – desired size of the pool_name cache pool’s metadata LV or 0 to use the default

  • mode (BlockDev.LVMCacheMode) – cache mode of the pool_name cache pool

  • flags (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:

GLib.Error

Returns:

whether the cache pool vg_name/pool_name was successfully created or not

Tech category: BlockDev.LVMTech.CACHE-BlockDev.LVMTechMode.CREATE

Return type:

bool

BlockDev.lvm_cache_detach(vg_name, cached_lv, destroy, extra)
Parameters:
  • vg_name (str) – name of the VG containing the cached_lv

  • cached_lv (str) – name of the cached LV to detach its cache from

  • destroy (bool) – whether to destroy the cache after detach or not

  • extra ([BlockDev.ExtraArg] or None) – extra options for the cache detachment (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_cache_get_default_md_size(cache_size)
Parameters:

cache_size (int) – size of the cache to determine MD size for

Raises:

GLib.Error

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:

int

BlockDev.lvm_cache_get_mode_from_str(mode_str)
Parameters:

mode_str (str) – string representation of a cache mode

Raises:

GLib.Error

Returns:

cache mode for the mode_str or BlockDev.LVMCacheMode.UNKNOWN if failed to determine

Tech category: always provided/supported

Return type:

BlockDev.LVMCacheMode

BlockDev.lvm_cache_get_mode_str(mode)
Parameters:

mode (BlockDev.LVMCacheMode) – mode to get the string representation for

Raises:

GLib.Error

Returns:

string representation of mode or None in case of error

Tech category: always provided/supported

Return type:

str

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 in

  • data_lv (str) – name of the LV that should become the data part of the new pool

  • metadata_lv (str) – name of the LV that should become the metadata part of the new pool

  • name (str or None) – name for the thin pool (if None, the name data_lv is inherited)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the thin pool creation (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

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:
  • vg_name (str) – name of the VG containing the cached_lv

  • cached_lv (str) – cached LV to get the name of the its pool LV for

Raises:

GLib.Error

Returns:

name of the cache pool LV used by the cached_lv or None in case of error

Tech category: BlockDev.LVMTech.CACHE-BlockDev.LVMTechMode.QUERY

Return type:

str

BlockDev.lvm_cache_stats(vg_name, cached_lv)
Parameters:
  • vg_name (str) – name of the VG containing the cached_lv

  • cached_lv (str) – cached LV to get stats for

Raises:

GLib.Error

Returns:

stats for the cached_lv or None in case of error

Tech category: BlockDev.LVMTech.CACHE-BlockDev.LVMTechMode.QUERY

Return type:

BlockDev.LVMCacheStats

BlockDev.lvm_delete_lv_tags(vg_name, lv_name, tags)
Parameters:
  • vg_name (str) – name of the VG that contains the LV to set tags on

  • lv_name (str) – name of the LV to set tags on

  • tags ([str]) – list of tags to remove

Raises:

GLib.Error

Returns:

whether the tags were successfully removed from device or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

bool

BlockDev.lvm_delete_pv_tags(device, tags)
Parameters:
  • device (str) – the device to set PV tags for

  • tags ([str]) – list of tags to remove

Raises:

GLib.Error

Returns:

whether the tags were successfully removed from device or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

bool

BlockDev.lvm_delete_vg_tags(vg_name, tags)
Parameters:
  • vg_name (str) – the VG to set tags on

  • tags ([str]) – list of tags to remove

Raises:

GLib.Error

Returns:

whether the tags were successfully removed from vg_name or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

bool

BlockDev.lvm_devices_add(device, devices_file, extra)
Parameters:
  • device (str) – device (PV) to add to the devices file

  • devices_file (str or None) – LVM devices file or None for default

  • extra ([BlockDev.ExtraArg] or None) – extra options for the lvmdevices command

Raises:

GLib.Error

Returns:

whether the device was successfully added to devices_file or not

Tech category: BlockDev.LVMTech.DEVICES no mode (it is ignored)

Return type:

bool

BlockDev.lvm_devices_delete(device, devices_file, extra)
Parameters:
  • device (str) – device (PV) to delete from the devices file

  • devices_file (str or None) – LVM devices file or None for default

  • extra ([BlockDev.ExtraArg] or None) – extra options for the lvmdevices command

Raises:

GLib.Error

Returns:

whether the device was successfully removed from devices_file or not

Tech category: BlockDev.LVMTech.DEVICES no mode (it is ignored)

Return type:

bool

BlockDev.lvm_error_quark()
Return type:

int

BlockDev.lvm_get_devices_filter()
Raises:

GLib.Error

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:

GLib.Error

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:

str

BlockDev.lvm_get_lv_physical_size(lv_size, pe_size)
Parameters:
  • lv_size (int) – LV size

  • pe_size (int) – PE size

Raises:

GLib.Error

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:

int

BlockDev.lvm_get_max_lv_size()
Raises:

GLib.Error

Returns:

maximum LV size in bytes

Tech category: BlockDev.LVMTech.CALCS no mode (it is ignored)

Return type:

int

BlockDev.lvm_get_supported_pe_sizes()
Raises:

GLib.Error

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:
  • size (int) – size of the thin pool

  • chunk_size (int) – chunk size of the thin pool or 0 to use the default

  • n_snapshots (int) – ignored

Raises:

GLib.Error

Returns:

recommended size of the metadata space for the specified pool

Tech category: BlockDev.LVMTech.THIN_CALCS no mode (it is ignored)

Return type:

int

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:
  • size (int) – size of the thin pool

  • pe_size (int) – PE size or 0 if the default value should be used

  • included (bool) – if padding is already included in the size

Raises:

GLib.Error

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:

int

BlockDev.lvm_get_vdo_compression_state_str(state)
Parameters:

state (BlockDev.LVMVDOCompressionState) – state to get the string representation for

Raises:

GLib.Error

Returns:

string representation of state or None in case of error

Tech category: always provided/supported

Return type:

str

BlockDev.lvm_get_vdo_index_state_str(state)
Parameters:

state (BlockDev.LVMVDOIndexState) – state to get the string representation for

Raises:

GLib.Error

Returns:

string representation of state or None in case of error

Tech category: always provided/supported

Return type:

str

BlockDev.lvm_get_vdo_operating_mode_str(mode)
Parameters:

mode (BlockDev.LVMVDOOperatingMode) – mode to get the string representation for

Raises:

GLib.Error

Returns:

string representation of mode or None in case of error

Tech category: always provided/supported

Return type:

str

BlockDev.lvm_get_vdo_write_policy_from_str(policy_str)
Parameters:

policy_str (str) – string representation of a policy

Raises:

GLib.Error

Returns:

write policy for the policy_str or BlockDev.LVMVDOWritePolicy.UNKNOWN if failed to determine

Tech category: always provided/supported

Return type:

BlockDev.LVMVDOWritePolicy

BlockDev.lvm_get_vdo_write_policy_str(policy)
Parameters:

policy (BlockDev.LVMVDOWritePolicy) – policy to get the string representation for

Raises:

GLib.Error

Returns:

string representation of policy or None in case of error

Tech category: always provided/supported

Return type:

str

BlockDev.lvm_is_supported_pe_size(size)
Parameters:

size (int) – size (in bytes) to test

Raises:

GLib.Error

Returns:

whether the given size is supported physical extent size or not

Tech category: BlockDev.LVMTech.CALCS no mode (it is ignored)

Return type:

bool

BlockDev.lvm_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.lvm_is_valid_thpool_chunk_size(size, discard)
Parameters:
  • size (int) – the size to be tested

  • discard (bool) – whether discard/TRIM is required to be supported or not

Raises:

GLib.Error

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:

bool

BlockDev.lvm_is_valid_thpool_md_size(size)
Parameters:

size (int) – the size to be tested

Raises:

GLib.Error

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:

bool

BlockDev.lvm_lvactivate(vg_name, lv_name, ignore_skip, shared, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-activated LV

  • lv_name (str) – name of the to-be-activated LV

  • ignore_skip (bool) – whether to ignore the skip flag or not

  • shared (bool) – whether to activate the LV in shared mode (used for shared LVM setups with lvmlockd, use False if not sure)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV activation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name LV was successfully activated or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

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 in

  • lv_name (str) – name of the to-be-created LV

  • size (int) – requested size of the new LV

  • type (str or None) – type of the new LV (“striped”, “raid1”,…, see lvcreate (8))

  • pv_list ([str] or None) – list of PVs the newly created LV should use or None if not specified

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV creation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the given vg_name/lv_name LV was successfully created or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.CREATE

Return type:

bool

BlockDev.lvm_lvdeactivate(vg_name, lv_name, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-deactivated LV

  • lv_name (str) – name of the to-be-deactivated LV

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV deactivation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name LV was successfully deactivated or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_lvinfo(vg_name, lv_name)
Parameters:
  • vg_name (str) – name of the VG that contains the LV to get information about

  • lv_name (str) – name of the LV to get information about

Raises:

GLib.Error

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.LVMLVdata

BlockDev.lvm_lvinfo_tree(vg_name, lv_name)
Parameters:
  • vg_name (str) – name of the VG that contains the LV to get information about

  • lv_name (str) – name of the LV to get information about

Raises:

GLib.Error

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.LVMLVdata

This function will fill out the data_lvs, metadata_lvs, and segs fields as well.

BlockDev.lvm_lvorigin(vg_name, lv_name)
Parameters:
  • vg_name (str) – name of the VG containing the queried LV

  • lv_name (str) – name of the queried LV

Raises:

GLib.Error

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:

str

BlockDev.lvm_lvremove(vg_name, lv_name, force, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-removed LV

  • lv_name (str) – name of the to-be-removed LV

  • force (bool) – whether to force removal or not

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV removal (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name LV was successfully removed or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.REMOVE

Return type:

bool

BlockDev.lvm_lvrename(vg_name, lv_name, new_name, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-renamed LV

  • lv_name (str) – name of the to-be-renamed LV

  • new_name (str) – new name for the vg_name/lv_name LV

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV rename (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_lvrepair(vg_name, lv_name, pv_list, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-repaired LV

  • lv_name (str) – name of the to-be-repaired LV

  • pv_list ([str]) – list of PVs to be used for the repair

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV repair (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name LV was successfully repaired or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_lvresize(vg_name, lv_name, size, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-resized LV

  • lv_name (str) – name of the to-be-resized LV

  • size (int) – the requested new size of the LV

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV resize (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name LV was successfully resized or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_lvs(vg_name)
Parameters:

vg_name (str or None) – name of the VG to get information about LVs from

Raises:

GLib.Error

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.LVMLVdata]

BlockDev.lvm_lvs_tree(vg_name)
Parameters:

vg_name (str or None) – name of the VG to get information about LVs from

Raises:

GLib.Error

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.LVMLVdata]

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 of

  • origin_name (str) – name of the LV a new snapshot should be created of

  • snapshot_name (str) – name of the to-be-created snapshot

  • size (int) – requested size for the snapshot

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV snapshot creation (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_lvsnapshotmerge(vg_name, snapshot_name, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-merged LV snapshot

  • snapshot_name (str) – name of the to-be-merged LV snapshot

  • extra ([BlockDev.ExtraArg] or None) – extra options for the LV snapshot merge (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_pvcreate(device, data_alignment, metadata_size, extra)
Parameters:
  • device (str) – the device to make PV from

  • data_alignment (int) – data (first PE) alignment or 0 to use the default

  • metadata_size (int) – size of the area reserved for metadata or 0 to use the default

  • extra ([BlockDev.ExtraArg] or None) – extra options for the PV creation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the PV was successfully created or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.CREATE

Return type:

bool

BlockDev.lvm_pvinfo(device)
Parameters:

device (str) – a PV to get information about or None

Raises:

GLib.Error

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.LVMPVdata

BlockDev.lvm_pvmove(src, dest, extra)
Parameters:
  • src (str) – the PV device to move extents off of

  • dest (str or None) – the PV device to move extents onto or None

  • extra ([BlockDev.ExtraArg] or None) – extra options for the PV move (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_pvremove(device, extra)
Parameters:
  • device (str) – the PV device to be removed/destroyed

  • extra ([BlockDev.ExtraArg] or None) – extra options for the PV removal (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the PV was successfully removed/destroyed or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.REMOVE

Return type:

bool

BlockDev.lvm_pvresize(device, size, extra)
Parameters:
  • device (str) – the device to resize

  • size (int) – the new requested size of the PV or 0 if it should be adjusted to device’s size

  • extra ([BlockDev.ExtraArg] or None) – extra options for the PV resize (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_pvs()
Raises:

GLib.Error

Returns:

information about PVs found in the system

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

[BlockDev.LVMPVdata]

BlockDev.lvm_pvscan(device, update_cache, extra)
Parameters:
  • device (str or None) – the device to scan for PVs or None

  • update_cache (bool) – whether to update the lvmetad cache or not

  • extra ([BlockDev.ExtraArg] or None) – extra options for the PV scan (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_round_size_to_pe(size, pe_size, roundup)
Parameters:
  • size (int) – size to be rounded

  • pe_size (int) – physical extent (PE) size or 0 to use the default

  • roundup (bool) – whether to round up or down (ceil or floor)

Raises:

GLib.Error

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:

int

BlockDev.lvm_set_devices_filter(devices)
Parameters:

devices ([str] or None) – list of devices for lvm commands to work on

Raises:

GLib.Error

Returns:

whether the devices filter was successfully set or not

Tech category: BlockDev.LVMTech.DEVICES no mode (it is ignored)

Return type:

bool

BlockDev.lvm_set_global_config(new_config)
Parameters:

new_config (str or None) – string representation of the new global LVM configuration to set or None to reset to default

Raises:

GLib.Error

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:

bool

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 LV

  • pool_name (str) – name of the pool LV providing extents for the to-be-created thin LV

  • lv_name (str) – name of the to-be-created thin LV

  • size (int) – requested virtual size of the to-be-created thin LV

  • extra ([BlockDev.ExtraArg] or None) – extra options for the thin LV creation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name thin LV was successfully created or not

Tech category: BlockDev.LVMTech.THIN-BlockDev.LVMTechMode.CREATE

Return type:

bool

BlockDev.lvm_thlvpoolname(vg_name, lv_name)
Parameters:
  • vg_name (str) – name of the VG containing the queried thin LV

  • lv_name (str) – name of the queried thin LV

Raises:

GLib.Error

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:

str

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 in

  • data_lv (str) – name of the LV that should become the data part of the new pool

  • metadata_lv (str) – name of the LV that should become the metadata part of the new pool

  • name (str or None) – name for the thin pool (if None, the name data_lv is inherited)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the thin pool creation (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

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 in

  • lv_name (str) – name of the to-be-created pool LV

  • size (int) – requested size of the to-be-created pool

  • md_size (int) – requested metadata size or 0 to use the default

  • chunk_size (int) – requested chunk size or 0 to use the default

  • profile (str or None) – profile to use (see lvm(8) for more information) or None to use the default

  • extra ([BlockDev.ExtraArg] or None) – extra options for the thin pool creation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the vg_name/lv_name thin pool was successfully created or not

Tech category: BlockDev.LVMTech.THIN-BlockDev.LVMTechMode.CREATE

Return type:

bool

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 of

  • origin_name (str) – name of the thin LV a new snapshot should be created of

  • snapshot_name (str) – name of the to-be-created snapshot

  • pool_name (str or None) – name of the thin pool to create the snapshot in or None if not specified

  • extra ([BlockDev.ExtraArg] or None) – extra options for the thin LV snapshot creation (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

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 LV

  • pool_name (str) – name of the VDO pool LV to disable compression on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO change (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether compression was successfully disabled on vg_name/pool_name LV or not

Tech category: BlockDev.LVMTech.VDO-BlockDev.LVMTechMode.MODIFY

Return type:

bool

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 LV

  • pool_name (str) – name of the VDO pool LV to disable deduplication on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO change (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether deduplication was successfully disabled on vg_name/pool_name LV or not

Tech category: BlockDev.LVMTech.VDO-BlockDev.LVMTechMode.MODIFY

Return type:

bool

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 LV

  • pool_name (str) – name of the VDO pool LV to enable compression on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO change (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether compression was successfully enabled on vg_name/pool_name LV or not

Tech category: BlockDev.LVMTech.VDO-BlockDev.LVMTechMode.MODIFY

Return type:

bool

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 LV

  • pool_name (str) – name of the VDO pool LV to enable deduplication on

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO change (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether deduplication was successfully enabled on vg_name/pool_name LV or not

Tech category: BlockDev.LVMTech.VDO-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_vdo_get_stats(vg_name, pool_name)
Parameters:
  • vg_name (str) – name of the VG that contains pool_name VDO pool

  • pool_name (str) – name of the VDO pool to get statistics for

Raises:

GLib.Error

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.LVMVDOStats

BlockDev.lvm_vdo_get_stats_full(vg_name, pool_name)
Parameters:
  • vg_name (str) – name of the VG that contains pool_name VDO pool

  • pool_name (str) – name of the VDO pool to get statistics for

Raises:

GLib.Error

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:

{str: str}

BlockDev.lvm_vdo_info(vg_name, lv_name)
Parameters:
  • vg_name (str) – name of the VG that contains the LV to get information about

  • lv_name (str) – name of the LV to get information about

Raises:

GLib.Error

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.LVMVDOPooldata

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_lv

  • pool_lv (str) – name of the LV that should become the new VDO pool LV

  • name (str or None) – name for the VDO LV or None for default name

  • virtual_size (int) – virtual size for the new VDO LV

  • index_memory (int) – amount of index memory (in bytes) or 0 for default

  • compression (bool) – whether to enable compression or not

  • deduplication (bool) – whether to enable deduplication or not

  • write_policy (BlockDev.LVMVDOWritePolicy) – write policy for the volume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO pool creation (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

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 in

  • lv_name (str) – name of the to-be-created VDO LV

  • pool_name (str or None) – name of the to-be-created VDO pool LV or None for default name

  • data_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 LV

  • index_memory (int) – amount of index memory (in bytes) or 0 for default

  • compression (bool) – whether to enable compression or not

  • deduplication (bool) – whether to enable deduplication or not

  • write_policy (BlockDev.LVMVDOWritePolicy) – write policy for the volume

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO LV creation (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

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 LV

  • pool_name (str) – name of the to-be-resized VDO pool LV

  • size (int) – the requested new size of the VDO pool LV

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO pool LV resize (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_vdo_resize(vg_name, lv_name, size, extra)
Parameters:
  • vg_name (str) – name of the VG containing the to-be-resized VDO LV

  • lv_name (str) – name of the to-be-resized VDO LV

  • size (int) – the requested new size of the VDO LV

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO LV resize (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_vdolvpoolname(vg_name, lv_name)
Parameters:
  • vg_name (str) – name of the VG containing the queried VDO LV

  • lv_name (str) – name of the queried VDO LV

Raises:

GLib.Error

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:

str

BlockDev.lvm_vgactivate(vg_name, extra)
Parameters:
  • vg_name (str) – name of the to be activated VG

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG activation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the VG was successfully activated or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_vgcreate(name, pv_list, pe_size, extra)
Parameters:
  • name (str) – name of the newly created VG

  • pv_list ([str]) – list of PVs the newly created VG should use

  • pe_size (int) – PE size or 0 if the default value should be used

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG creation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the VG name was successfully created or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.CREATE

Return type:

bool

BlockDev.lvm_vgdeactivate(vg_name, extra)
Parameters:
  • vg_name (str) – name of the to be deactivated VG

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG deactivation (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the VG was successfully deactivated or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_vgextend(vg_name, device, extra)
Parameters:
  • vg_name (str) – name of the to be extended VG

  • device (str) – PV device to extend the vg_name VG with

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG extension (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_vginfo(vg_name)
Parameters:

vg_name (str) – a VG to get information about

Raises:

GLib.Error

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.LVMVGdata

BlockDev.lvm_vglock_start(vg_name, extra)
Parameters:
  • vg_name (str) – a shared VG to start the lockspace in lvmlockd

  • extra ([BlockDev.ExtraArg] or None) – extra options for the vgchange command (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the lock was successfully started for vg_name or not

Tech category: BlockDev.LVMTech.SHARED-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_vglock_stop(vg_name, extra)
Parameters:
  • vg_name (str) – a shared VG to stop the lockspace in lvmlockd

  • extra ([BlockDev.ExtraArg] or None) – extra options for the vgchange command (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the lock was successfully stopped for vg_name or not

Tech category: BlockDev.LVMTech.SHARED-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_vgreduce(vg_name, device, extra)
Parameters:
  • vg_name (str) – name of the to be reduced VG

  • device (str or None) – PV device the vg_name VG should be reduced of or None if the VG should be reduced of the missing PVs

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG reduction (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.lvm_vgremove(vg_name, extra)
Parameters:
  • vg_name (str) – name of the to be removed VG

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG removal (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the VG was successfully removed or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.REMOVE

Return type:

bool

BlockDev.lvm_vgrename(old_vg_name, new_vg_name, extra)
Parameters:
  • old_vg_name (str) – old name of the VG to rename

  • new_vg_name (str) – new name for the old_vg_name VG

  • extra ([BlockDev.ExtraArg] or None) – extra options for the VG rename (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the VG was successfully renamed or not

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.MODIFY

Return type:

bool

BlockDev.lvm_vgs()
Raises:

GLib.Error

Returns:

information about VGs found in the system

Tech category: BlockDev.LVMTech.BASIC-BlockDev.LVMTechMode.QUERY

Return type:

[BlockDev.LVMVGdata]

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 LVs

  • data_lv (str) – data LV to attach the cache_lv to

  • cache_lv (str) – cache (fast) LV to attach to the data_lv

  • extra ([BlockDev.ExtraArg] or None) – extra options for the cache attachment (just passed to LVM as is)

Raises:

GLib.Error

Returns:

whether the cache_lv was successfully attached to the data_lv or not

Tech category: BlockDev.LVMTech.WRITECACHE-BlockDev.LVMTechMode.MODIFY

Return type:

bool

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 in

  • lv_name (str) – name of the cached LV to create

  • data_size (int) – size of the data LV

  • cache_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:

GLib.Error

Returns:

whether the cached LV lv_name was successfully created or not

Tech category: BlockDev.LVMTech.WRITECACHE-BlockDev.LVMTechMode.CREATE

Return type:

bool

BlockDev.lvm_writecache_detach(vg_name, cached_lv, destroy, extra)
Parameters:
  • vg_name (str) – name of the VG containing the cached_lv

  • cached_lv (str) – name of the cached LV to detach its cache from

  • destroy (bool) – whether to destroy the cache after detach or not

  • extra ([BlockDev.ExtraArg] or None) – extra options for the cache detachment (just passed to LVM as is)

Raises:

GLib.Error

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:

bool

BlockDev.md_activate(raid_spec, members, uuid, start_degraded, extra)
Parameters:
  • raid_spec (str or None) – specification of the RAID device (name, node or path) to activate (if not given “–scan” is implied and members is ignored)

  • members ([str] or None) – member devices to be considered for device activation

  • uuid (str or None) – UUID (in the MD RAID format!) of the MD RAID to activate

  • start_degraded (bool) – whether to start the array even if it’s degraded

  • extra ([BlockDev.ExtraArg] or None) – extra options for the activation (right now passed to the ‘mdadm’ utility)

Raises:

GLib.Error

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:

bool

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 into

  • device (str) – name of the device to add to the raid_spec RAID device

  • raid_devs (int) – number of devices the raid_spec RAID should actively use or 0 to leave unspecified (see below)

  • extra ([BlockDev.ExtraArg] or None) – extra options for the addition (right now passed to the ‘mdadm’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.md_canonicalize_uuid(uuid)
Parameters:

uuid (str) – UUID to canonicalize

Raises:

GLib.Error

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:

str

BlockDev.md_create(device_name, level, disks, spares, version, bitmap, chunk_size, extra)
Parameters:
  • device_name (str) – name of the device to create

  • level (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 devices

  • version (str or None) – metadata version

  • bitmap (str or None) – write-intent bitmap location (‘none’, ‘internal’) or None to let mdadm decide (i.e. internal > 100GB)

  • chunk_size (int) – chunk size of the device to create

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mdadm’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.md_deactivate(raid_spec)
Parameters:

raid_spec (str) – specification of the RAID device (name, node or path)

Raises:

GLib.Error

Returns:

whether the RAID device raid_spec was successfully deactivated or not

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.MODIFY

Return type:

bool

BlockDev.md_denominate(device)
Parameters:

device (str) – device to denominate (remove from its appropriate RAID) as a MD RAID device

Raises:

GLib.Error

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:

bool

BlockDev.md_destroy(device)
Parameters:

device (str) – device to destroy MD RAID metadata on

Raises:

GLib.Error

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:

bool

BlockDev.md_detail(raid_spec)
Parameters:

raid_spec (str) – specification of the RAID device (name, node or path) to examine

Raises:

GLib.Error

Returns:

information about the MD RAID raid_spec

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.QUERY

Return type:

BlockDev.MDDetailData

BlockDev.md_error_quark()
Return type:

int

BlockDev.md_examine(device)
Parameters:

device (str) – name of the device (a member of an MD RAID) to examine

Raises:

GLib.Error

Returns:

information about the MD RAID extracted from the device

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.QUERY

Return type:

BlockDev.MDExamineData

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:

GLib.Error

Returns:

bitmap location for raid_spec

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.QUERY

Return type:

str

BlockDev.md_get_md_uuid(uuid)
Parameters:

uuid (str) – UUID to transform into format used by MD RAID

Raises:

GLib.Error

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:1eb47236

Tech category: always available

Return type:

str

BlockDev.md_get_status(raid_spec)
Parameters:

raid_spec (str) – specification of the RAID device (name, node or path) to get status

Raises:

GLib.Error

Returns:

status of the raid_spec RAID.

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.QUERY

Return type:

str

BlockDev.md_get_superblock_size(member_size, version)
Parameters:
  • member_size (int) – size of an array member

  • version (str or None) – metadata version or None to use the current default version

Raises:

GLib.Error

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:

int

BlockDev.md_is_tech_avail(tech, mode)
Parameters:
  • tech (BlockDev.MDTech) – the queried tech

  • mode (int) – a bit mask of queried modes of operation for tech

Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.md_name_from_node(node)
Parameters:

node (str) – path of the MD RAID’s device node

Raises:

GLib.Error

Returns:

name of the MD RAID the device node belongs to or None in case of error

Tech category: always available

Return type:

str

BlockDev.md_node_from_name(name)
Parameters:

name (str) – name of the MD RAID

Raises:

GLib.Error

Returns:

device node of the name MD RAID or None in case of error

Tech category: always available

Return type:

str

BlockDev.md_nominate(device)
Parameters:

device (str) – device to nominate (add to its appropriate RAID) as a MD RAID device

Raises:

GLib.Error

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:

bool

BlockDev.md_remove(raid_spec, device, fail, extra)
Parameters:
  • raid_spec (str) – specification of the RAID device (name, node or path) to remove device from

  • device (str) – device to remove from the raid_spec RAID

  • fail (bool) – whether to mark the device as failed before removing

  • extra ([BlockDev.ExtraArg] or None) – extra options for the removal (right now passed to the ‘mdadm’ utility)

Raises:

GLib.Error

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:

bool

BlockDev.md_request_sync_action(raid_spec, action)
Parameters:
  • raid_spec (str) – specification of the RAID device (name, node or path) to request sync action on

  • action (str) – requested sync action (resync, recovery, check, repair or idle)

Raises:

GLib.Error

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:

bool

BlockDev.md_run(raid_spec)
Parameters:

raid_spec (str) – specification of the (possibly degraded) RAID device (name, node or path) to be started

Raises:

GLib.Error

Returns:

whether the raid_spec was successfully started or not

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.MODIFY

Return type:

bool

BlockDev.md_set_bitmap_location(raid_spec, location)
Parameters:
  • raid_spec (str) – specification of the RAID device (name, node or path) to set the bitmap location

  • location (str) – bitmap location (none, internal or path)

Raises:

GLib.Error

Returns:

whether location was successfully set for raid_spec

Tech category: BlockDev.MDTech.MD_TECH_MDRAID-BlockDev.MDTechMode.MODIFY

Return type:

bool

BlockDev.mpath_error_quark()
Return type:

int

BlockDev.mpath_flush_mpaths()
Raises:

GLib.Error

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:

bool

BlockDev.mpath_get_mpath_members()
Raises:

GLib.Error

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:

GLib.Error

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:

bool

BlockDev.mpath_is_tech_avail(tech, mode)
Parameters:
  • tech (BlockDev.MpathTech) – the queried tech

  • mode (int) – a bit mask of queried modes of operation for tech

Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.mpath_set_friendly_names(enabled)
Parameters:

enabled (bool) – whether friendly names should be enabled or not

Raises:

GLib.Error

Returns:

if successfully set or not

Tech category: BlockDev.MpathTech.FRIENDLY_NAMES-BlockDev.MpathTechMode.MODIFY

Return type:

bool

BlockDev.nvdimm_error_quark()
Return type:

int

BlockDev.nvdimm_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.nvdimm_list_namespaces(bus, region, idle, extra)
Parameters:
  • bus (str or None) – return only namespaces on given bus (specified by name), None may be specified to return namespaces from all buses

  • region (str or None) – return only namespaces on given region (specified by regionX name or region id), None may be specified to return namespaces from all regions

  • idle (bool) – whether to list idle (not enabled) namespaces too

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘ndctl’ utility)

Raises:

GLib.Error

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:

[BlockDev.NVDIMMNamespaceInfo]

BlockDev.nvdimm_namespace_disable(namespace, extra)
Parameters:
  • namespace (str) – name of the namespace to disable

  • extra ([BlockDev.ExtraArg] or None) – extra options (currently unused)

Raises:

GLib.Error

Returns:

whether the namespace was successfully disabled or not

Tech category: BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE-BlockDev.NVDIMMTechMode.ACTIVATE_DEACTIVATE

Return type:

bool

BlockDev.nvdimm_namespace_enable(namespace, extra)
Parameters:
  • namespace (str) – name of the namespace to enable

  • extra ([BlockDev.ExtraArg] or None) – extra options (currently unused)

Raises:

GLib.Error

Returns:

whether the namespace was successfully enabled or not

Tech category: BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE-BlockDev.NVDIMMTechMode.ACTIVATE_DEACTIVATE

Return type:

bool

BlockDev.nvdimm_namespace_get_devname(device)
Parameters:

device (str) – name or path of a block device (e.g. “/dev/pmem0”)

Raises:

GLib.Error

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:

str

BlockDev.nvdimm_namespace_get_mode_from_str(mode_str)
Parameters:

mode_str (str) – string representation of mode

Raises:

GLib.Error

Returns:

mode matching the mode_str given or BlockDev.NVDIMMNamespaceMode.UNKNOWN in case of no match

Tech category: always available

Return type:

BlockDev.NVDIMMNamespaceMode

BlockDev.nvdimm_namespace_get_mode_str(mode)
Parameters:

mode (BlockDev.NVDIMMNamespaceMode) – mode to get string representation of

Raises:

GLib.Error

Returns:

string representation of mode or None in case of error

Tech category: always available

Return type:

str

BlockDev.nvdimm_namespace_get_supported_sector_sizes(mode)
Parameters:

mode (BlockDev.NVDIMMNamespaceMode) – namespace mode

Raises:

GLib.Error

Returns:

list of supported sector sizes for mode

Tech category: BlockDev.NVDIMMTech.NVDIMM_TECH_NAMESPACE-BlockDev.NVDIMMTechMode.QUERY

Return type:

[int]

BlockDev.nvdimm_namespace_info(namespace, extra)
Parameters:
  • namespace (str) – namespace to get information about

  • extra ([BlockDev.ExtraArg] or None) – extra options (currently unused)

Raises:

GLib.Error

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:

BlockDev.NVDIMMNamespaceInfo

BlockDev.nvdimm_namespace_reconfigure(namespace, mode, force, extra)
Parameters:
  • namespace (str) – name of the namespace to reconfigure

  • mode (BlockDev.NVDIMMNamespaceMode) – mode type to set (memory/sector/raw/dax)

  • force (bool) – whether to use force to reconfigure an active namespace

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘ndctl’ utility)

Raises:

GLib.Error

Returns:

whether namespace was successfully reconfigured or not

Return type:

bool

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 or None) – The network address of the Controller. For transports using IP addressing (e.g. rdma) this should be an IP-based address.

  • transport_svcid (str or None) – 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 the RDMA transport is 4420.

  • host_traddr (str or None) – 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 or None) – The network interface used on the host to connect to the Controller (e.g. IP eth1, enp2s0). This forces the connection to be made on a specific interface instead of letting the system decide.

  • host_nqn (str or None) – Overrides the default Host NQN that identifies the NVMe Host. If this option is None, 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 or None) – User-defined host UUID or None to use default (as defined in /etc/nvme/hostid)

  • extra ([BlockDev.ExtraArg] or None) – Additional arguments.

Raises:

GLib.Error

Returns:

True if the subsystem was connected successfully, False otherwise with error set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

bool

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 of nvme-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:
Raises:

GLib.Error

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:

bool

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 using BlockDev.nvme_get_self_test_log().

BlockDev.nvme_disconnect(subsysnqn)
Parameters:

subsysnqn (str) – The name of the NVMe subsystem to disconnect.

Raises:

GLib.Error

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:

bool

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:

GLib.Error

Returns:

True if the controller was disconnected successfully, False otherwise with error set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

bool

Disconnects and removes a NVMe over Fabrics controller represented by a block device path.

BlockDev.nvme_error_quark()
Return type:

int

BlockDev.nvme_find_ctrls_for_ns(ns_sysfs_path, subsysnqn, host_nqn, host_id)
Parameters:
  • ns_sysfs_path (str) – NVMe namespace device file.

  • subsysnqn (str or None) – Limit matching to the specified subsystem NQN.

  • host_nqn (str or None) – Limit matching to the specified host NQN.

  • host_id (str or None) – Limit matching to the specified host ID.

Raises:

GLib.Error

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:
Raises:

GLib.Error

Returns:

True if the format command finished successfully, False otherwise with error set.

Tech category: BlockDev.NVMETech.NVME-BlockDev.NVMETechMode.MANAGE

Return type:

bool

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 value 0 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 and BlockDev.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:

GLib.Error

Returns:

the Host NQN string or None with error set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

str

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:

GLib.Error

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:

BlockDev.NVMEControllerInfo

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:

GLib.Error

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:

[BlockDev.NVMEErrorLogEntry]

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:

GLib.Error

Returns:

the Host ID string or an empty string if none set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

str

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:

GLib.Error

Returns:

the Host NQN string or an empty string if none set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

str

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:

GLib.Error

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:

BlockDev.NVMENamespaceInfo

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:

GLib.Error

Returns:

sanitize log data or None in case of an error (with error set).

Tech category: BlockDev.NVMETech.NVME-BlockDev.NVMETechMode.INFO

Return type:

BlockDev.NVMESanitizeLog

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:

GLib.Error

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:

BlockDev.NVMESelfTestLog

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:

GLib.Error

Returns:

health log data or None in case of an error (with error set).

Tech category: BlockDev.NVMETech.NVME-BlockDev.NVMETechMode.INFO

Return type:

BlockDev.NVMESmartLog

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_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:

GLib.Error

Returns:

True if the format command finished successfully, False otherwise with error set.

Tech category: BlockDev.NVMETech.NVME-BlockDev.NVMETechMode.MANAGE

Return type:

bool

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 an BlockDev.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) – A BlockDev.NVMESelfTestResult.

Raises:

GLib.Error

Returns:

A string representation of result for use as an identifier string or None when the code is unknown.

Return type:

str

BlockDev.nvme_set_host_id(host_id)
Parameters:

host_id (str) – The Host ID.

Raises:

GLib.Error

Returns:

True if the value was set successfully or False otherwise with error set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

bool

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:

GLib.Error

Returns:

True if the value was set successfully or False otherwise with error set.

Tech category: BlockDev.NVMETech.FABRICS-BlockDev.NVMETechMode.INITIATOR

Return type:

bool

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 on

  • type (BlockDev.PartTypeReq) – type of the partition to create (if BlockDev.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:

GLib.Error

Returns:

specification of the created partition or None in case of error

NOTE: 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.PartSpec

BlockDev.part_create_table(disk, type, ignore_existing)
Parameters:
  • disk (str) – path of the disk block device to create partition table on

  • type (BlockDev.PartTableType) – type of the partition table to create

  • ignore_existing (bool) – whether to ignore/overwrite the existing table or not (reports an error if False and there’s some table on disk)

Raises:

GLib.Error

Returns:

whether the partition table was successfully created or not

Tech category: BlockDev.PartTechMode.CREATE_TABLE + the tech according to type

Return type:

bool

BlockDev.part_delete_part(disk, part)
Parameters:
  • disk (str) – disk to remove the partition from

  • part (str) – partition to remove

Raises:

GLib.Error

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:

bool

BlockDev.part_error_quark()
Return type:

int

BlockDev.part_get_best_free_region(disk, type, size)
Parameters:
  • disk (str) – disk to get the best free region for

  • type (BlockDev.PartType) – type of the partition that is planned to be added

  • size (int) – size of the partition to be added

Raises:

GLib.Error

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 type BlockDev.PartType.LOGICAL, the smallest possible space that *is* in an extended partition is found. For BlockDev.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.PartSpec

BlockDev.part_get_disk_free_regions(disk)
Parameters:

disk (str) – disk to get free regions for

Raises:

GLib.Error

Returns:

specs of the free regions from disk or None in case of error

Tech category: BlockDev.PartTechMode.QUERY_TABLE + the tech according to the partition table type

Return type:

[BlockDev.PartSpec]

BlockDev.part_get_disk_parts(disk)
Parameters:

disk (str) – disk to get information about partitions for

Raises:

GLib.Error

Returns:

specs of the partitions from disk or None in case of error

Tech category: BlockDev.PartTechMode.QUERY_TABLE + the tech according to the partition table type

Return type:

[BlockDev.PartSpec]

BlockDev.part_get_disk_spec(disk)
Parameters:

disk (str) – disk to get information about

Raises:

GLib.Error

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.PartDiskSpec

BlockDev.part_get_part_by_pos(disk, position)
Parameters:
  • disk (str) – disk to remove the partition from

  • position (int) – position (in bytes) determining the partition

Raises:

GLib.Error

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.PartSpec

BlockDev.part_get_part_spec(disk, part)
Parameters:
  • disk (str) – disk to remove the partition from

  • part (str) – partition to get spec for

Raises:

GLib.Error

Returns:

spec of the part partition from disk or None in case of error

Tech category: BlockDev.PartTechMode.QUERY_PART + the tech according to the partition table type

Return type:

BlockDev.PartSpec

BlockDev.part_get_part_table_type_str(type)
Parameters:

type (BlockDev.PartTableType) – table type to get string representation for

Raises:

GLib.Error

Returns:

string representation of table_type

Tech category: the tech according to type

Return type:

str

BlockDev.part_get_type_str(type)
Parameters:

type (BlockDev.PartType) – type to get string representation for

Raises:

GLib.Error

Returns:

string representation of type

Tech category: always available

Return type:

str

BlockDev.part_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.part_resize_part(disk, part, size, align)
Parameters:
  • disk (str) – disk containing the partition

  • part (str) – partition to resize

  • size (int) – new partition size, 0 for maximal size

  • align (BlockDev.PartAlign) – alignment to use for the partition end

Raises:

GLib.Error

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:

bool

BlockDev.part_set_part_attributes(disk, part, attrs)
Parameters:
  • disk (str) – device the partition belongs to

  • part (str) – partition the attributes should be set for

  • attrs (int) – GPT attributes to set on part

Raises:

GLib.Error

Returns:

whether the attrs GPT attributes were successfully set for part or not

Tech category: BlockDev.PartTech.GPT-BlockDev.PartTechMode.MODIFY_PART

Return type:

bool

BlockDev.part_set_part_bootable(disk, part, bootable)
Parameters:
  • disk (str) – device the partition belongs to

  • part (str) – partition the bootable flag should be set for

  • bootable (bool) – whether to set or unset the bootable flag

Raises:

GLib.Error

Returns:

whether the bootable flag was successfully set for part or not

Tech category: BlockDev.PartTech.MBR-BlockDev.PartTechMode.MODIFY_PART

Return type:

bool

BlockDev.part_set_part_id(disk, part, part_id)
Parameters:
  • disk (str) – device the partition belongs to

  • part (str) – partition the ID should be set for

  • part_id (str) – partition Id

Raises:

GLib.Error

Returns:

whether the part_id type was successfully set for part or not

Tech category: BlockDev.PartTech.MBR-BlockDev.PartTechMode.MODIFY_PART

Return type:

bool

BlockDev.part_set_part_name(disk, part, name)
Parameters:
  • disk (str) – device the partition belongs to

  • part (str) – partition the name should be set for

  • name (str) – name to set

Raises:

GLib.Error

Returns:

whether the name was successfully set or not

Tech category: BlockDev.PartTech.GPT-BlockDev.PartTechMode.MODIFY_PART

Return type:

bool

BlockDev.part_set_part_type(disk, part, type_guid)
Parameters:
  • disk (str) – device the partition belongs to

  • part (str) – partition the type should be set for

  • type_guid (str) – GUID of the type

Raises:

GLib.Error

Returns:

whether the type_guid type was successfully set for part or not

Tech category: BlockDev.PartTech.GPT-BlockDev.PartTechMode.MODIFY_PART

Return type:

bool

BlockDev.part_set_part_uuid(disk, part, uuid)
Parameters:
  • disk (str) – device the partition belongs to

  • part (str) – partition the UUID should be set for

  • uuid (str) – partition UUID to set

Raises:

GLib.Error

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:

bool

BlockDev.reinit(require_plugins, reload, log_func)
Parameters:
  • require_plugins ([BlockDev.PluginSpec] or None) – None-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) or None to load all plugins

  • reload (bool) – whether to reload the already loaded plugins or not

  • log_func (BlockDev.UtilsLogFunc or None) – logging function to use or None to keep the old one

Raises:

GLib.Error

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:

bool

BlockDev.swap_error_quark()
Return type:

int

BlockDev.swap_is_tech_avail(tech, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the tech-mode combination is available – supported by the plugin implementation and having all the runtime dependencies available

Return type:

bool

BlockDev.swap_mkswap(device, label, uuid, extra)
Parameters:
  • device (str) – a device to create swap space on

  • label (str or None) – a label for the swap space device

  • uuid (str or None) – UUID for the swap space device

  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘mkswap’ utility)

Raises:

GLib.Error

Returns:

whether the swap space was successfully created or not

Tech category: BlockDev.SwapTech.SWAP_TECH_SWAP-BlockDev.SwapTechMode.CREATE

Return type:

bool

BlockDev.swap_set_label(device, label)
Parameters:
  • device (str) – a device to set label on

  • label (str) – label that will be set

Raises:

GLib.Error

Returns:

whether the label was successfully set or not

Tech category: BlockDev.SwapTech.SWAP_TECH_SWAP-BlockDev.SwapTechMode.SET_LABEL

Return type:

bool

BlockDev.swap_set_uuid(device, uuid)
Parameters:
  • device (str) – a device to set UUID on

  • uuid (str) – UUID that will be set

Raises:

GLib.Error

Returns:

whether the UUID was successfully set or not

Tech category: BlockDev.SwapTech.SWAP_TECH_SWAP-BlockDev.SwapTechMode.SET_UUID

Return type:

bool

BlockDev.swap_swapoff(device)
Parameters:

device (str) – swap device to deactivate

Raises:

GLib.Error

Returns:

whether the swap device was successfully deactivated or not

Tech category: BlockDev.SwapTech.SWAP_TECH_SWAP-BlockDev.SwapTechMode.ACTIVATE_DEACTIVATE

Return type:

bool

BlockDev.swap_swapon(device, priority)
Parameters:
  • device (str) – swap device to activate

  • priority (int) – priority of the activated device or -1 to use the default

Raises:

GLib.Error

Returns:

whether the swap device was successfully activated or not

Tech category: BlockDev.SwapTech.SWAP_TECH_SWAP-BlockDev.SwapTechMode.ACTIVATE_DEACTIVATE

Return type:

bool

BlockDev.swap_swapstatus(device)
Parameters:

device (str) – swap device to get status of

Raises:

GLib.Error

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:

bool

BlockDev.try_init(request_plugins, log_func)
Parameters:
Raises:

GLib.Error

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() AND BlockDev.ensure_init(), FAILURE TO LOAD A PLUGIN IS NOT CONSIDERED ERROR*

loaded_plugin_names:

names of the successfully loaded plugins

Return type:

(bool, loaded_plugin_names: [str])

BlockDev.try_reinit(require_plugins, reload, log_func)
Parameters:
  • require_plugins ([BlockDev.PluginSpec] or None) – None-terminated list of plugins that should be loaded (if no so_name is specified for the plugin, the default is used) or None to load all plugins

  • reload (bool) – whether to reload the already loaded plugins or not

  • log_func (BlockDev.UtilsLogFunc or None) – logging function to use or None to keep the old one

Raises:

GLib.Error

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() AND BlockDev.ensure_init(), FAILURE TO LOAD A PLUGIN IS NOT CONSIDERED ERROR*

loaded_plugin_names:

names of the successfully loaded plugins

Return type:

(bool, loaded_plugin_names: [str])

BlockDev.utils_check_linux_version(major, minor, micro)
Parameters:
  • major (int) – Minimal major linux kernel version.

  • minor (int) – Minimal minor linux kernel version.

  • micro (int) – Minimal micro linux kernel version.

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:

int

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 check

  • version (str or None) – minimum required version of the utility or None if no version is required

  • version_arg (str or None) – argument to use with the util to get version info or None to use “–version”

  • version_regexp (str or None) – regexp to extract version from the version info or None if only version is printed by “$ util version_arg"

Raises:

GLib.Error

Returns:

whether the util is available in a version >= version or not (error is set in such case).

Return type:

bool

BlockDev.utils_dbus_service_available(connection, bus_type, bus_name, obj_prefix)
Parameters:
  • connection (Gio.DBusConnection or None) – existing Gio.DBusConnection or None

  • bus_type (Gio.BusType) – bus type (system or session), ignored if connection is specified

  • bus_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:

GLib.Error

Returns:

whether the service was found in the system

Return type:

bool

BlockDev.utils_echo_str_to_file(str, file_path)
Parameters:
  • str (str) – string to write to file_path

  • file_path (str) – path to file

Raises:

GLib.Error

Returns:

whether the str was successfully written to file_path or not.

Return type:

bool

BlockDev.utils_exec_and_capture_output(argv, extra)
Parameters:
Raises:

GLib.Error

Returns:

whether the argv was successfully executed capturing the output or not

output:

variable to store output to

Return type:

(bool, output: str)

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:
Raises:

GLib.Error

Returns:

whether the argv was successfully executed (no error and exit code 0) or not

Return type:

bool

BlockDev.utils_exec_and_report_error_no_progress(argv, extra)
Parameters:
Raises:

GLib.Error

Returns:

whether the argv was successfully executed (no error and exit code 0) or not

Return type:

bool

BlockDev.utils_exec_and_report_progress(argv, extra, prog_extract)
Parameters:
Raises:

GLib.Error

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:

(bool, proc_status: int)

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:
Raises:

GLib.Error

Returns:

whether the argv was successfully executed (no error and exit code 0) or not

status:

place to store the status

Return type:

(bool, status: int)

BlockDev.utils_exec_with_input(argv, input, extra)
Parameters:
  • argv ([str]) – the argv array for the call

  • input (str or None) – input for the executed program

  • extra ([BlockDev.ExtraArg] or None) – extra arguments

Raises:

GLib.Error

Returns:

whether the argv was successfully executed (no error and exit code 0) or not

Return type:

bool

Parameters:

dev_spec (str) – specification of the device (e.g. “/dev/sda”, any symlink, or the name of a file under “/dev”)

Raises:

GLib.Error

Returns:

a list of all symlinks (known to udev) for the device specified with dev_spec or None in case of error

Return type:

[str]

BlockDev.utils_get_linux_version()
Raises:

GLib.Error

Returns:

Detected Linux kernel version or None in case of an error. The returned value belongs to the library, do not free.

Return type:

BlockDev.UtilsLinuxVersion

Retrieves version of currently running Linux kernel. Acts also as an initializer for statically cached data.

BlockDev.utils_get_next_task_id()
Return type:

int

BlockDev.utils_have_kernel_module(module_name)
Parameters:

module_name (str) – name of the kernel module to check

Raises:

GLib.Error

Returns:

whether the module_name was found in the system, either as a module or built-in in the kernel

Return type:

bool

BlockDev.utils_init_logging(new_log_func)
Parameters:

new_log_func (BlockDev.UtilsLogFunc or None) – logging function to use or None to disable logging; use BlockDev.utils_log_stdout to reset to the default behaviour

Raises:

GLib.Error

Returns:

whether logging was successfully initialized or not

Return type:

bool

BlockDev.utils_init_prog_reporting(new_prog_func)
Parameters:

new_prog_func (BlockDev.UtilsProgFunc or None) – progress reporting function to use or None to reset to default

Raises:

GLib.Error

Returns:

whether progress reporting was successfully initialized or not

Return type:

bool

BlockDev.utils_init_prog_reporting_thread(new_prog_func)
Parameters:

new_prog_func (BlockDev.UtilsProgFunc or None) – progress reporting function to use on current thread or None to reset to default or global

Raises:

GLib.Error

Returns:

whether progress reporting was successfully initialized or not

Return type:

bool

BlockDev.utils_load_kernel_module(module_name, options)
Parameters:
  • module_name (str) – name of the kernel module to load

  • options (str or None) – module options

Raises:

GLib.Error

Returns:

whether the module_name was successfully loaded or not

Return type:

bool

BlockDev.utils_log(level, msg)
Parameters:
  • level (int) – log level

  • msg (str) – log message

BlockDev.utils_log_stdout(level, msg)
Parameters:
  • level (int) – log level

  • msg (str) – log message

Convenient function for logging to stdout. Can be used as BlockDev.UtilsLogFunc.

BlockDev.utils_log_task_status(task_id, msg)
Parameters:
  • task_id (int) – ID of the task the status of which is being logged

  • msg (str) – log message

BlockDev.utils_mute_prog_reporting_thread()
Raises:

GLib.Error

Returns:

whether progress reporting for the current thread was successfully muted (deinitialized even in presence of a global reporting function) or not

Return type:

bool

BlockDev.utils_prog_reporting_initialized()
Returns:

True if progress reporting has been initialized, i.e. a reporting function was set up with either BlockDev.utils_init_prog_reporting or BlockDev.utils_init_prog_reporting_thread (takes precedence). False if BlockDev.utils_mute_prog_reporting_thread was used to mute the thread.

Return type:

bool

BlockDev.utils_report_finished(task_id, msg)
Parameters:
  • task_id (int) – ID of the task/action

  • msg (str) – message describing the status of the task/action

BlockDev.utils_report_progress(task_id, completion, msg)
Parameters:
  • task_id (int) – ID of the task/action

  • completion (int) – percentage of completion

  • msg (str) – message describing the status of the task/action

BlockDev.utils_report_started(msg)
Parameters:

msg (str) – message describing the started task/action

Returns:

ID of the started task/action

Return type:

int

BlockDev.utils_resolve_device(dev_spec)
Parameters:

dev_spec (str) – specification of the device (e.g. “/dev/sda”, any symlink, or the name of a file under “/dev”)

Raises:

GLib.Error

Returns:

the full real path of the device (e.g. “/dev/md126” for “/dev/md/my_raid”) or None in case of error

Return type:

str

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 levels BlockDev.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:

GLib.Error

Returns:

whether the module_name was successfully unloaded or not

Return type:

bool

BlockDev.utils_version_cmp(ver_string1, ver_string2)
Parameters:
  • ver_string1 (str) – first version string

  • ver_string2 (str) – second version string

Raises:

GLib.Error

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:

int