Functions

  btrfs_add_device (mountpoint, device, extra)
  btrfs_change_label (mountpoint, label, extra)
  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_open (device, name, pass_data, 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_generate_backup_passphrase ()
  crypto_integrity_info (device)
  crypto_is_tech_avail (tech, mode)
  crypto_luks_add_key (device, pass_, key_file, npass, nkey_file)
  crypto_luks_add_key_blob (device, pass_data, npass_data)
  crypto_luks_change_key (device, pass_, npass)
  crypto_luks_change_key_blob (device, pass_data, npass_data)
  crypto_luks_close (luks_device)
  crypto_luks_format (device, cipher, key_size, passphrase, key_file, min_entropy)
  crypto_luks_format_blob (device, cipher, key_size, pass_data, min_entropy)
  crypto_luks_format_luks2 (device, cipher, key_size, passphrase, key_file, min_entropy, luks_version, extra)
  crypto_luks_format_luks2_blob (device, cipher, key_size, pass_data, min_entropy, luks_version, extra)
  crypto_luks_get_metadata_size (device)
  crypto_luks_header_backup (device, backup_file)
  crypto_luks_header_restore (device, backup_file)
  crypto_luks_info (luks_device)
  crypto_luks_kill_slot (device, slot)
  crypto_luks_open (device, name, passphrase, key_file, read_only)
  crypto_luks_open_blob (device, name, pass_data, read_only)
  crypto_luks_remove_key (device, pass_, key_file)
  crypto_luks_remove_key_blob (device, pass_data)
  crypto_luks_resize (luks_device, size)
  crypto_luks_resize_luks2 (luks_device, size, passphrase, key_file)
  crypto_luks_resize_luks2_blob (luks_device, size, pass_data)
  crypto_luks_resume (luks_device, passphrase, key_file)
  crypto_luks_resume_blob (luks_device, pass_data)
  crypto_luks_status (luks_device)
  crypto_luks_suspend (luks_device)
  crypto_luks_uuid (device)
  crypto_tc_close (tc_device)
  crypto_tc_open (device, name, pass_data, read_only)
  crypto_tc_open_full (device, name, pass_data, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only)
  dm_activate_raid_set (name)
  dm_create_linear (map_name, device, length, uuid)
  dm_deactivate_raid_set (name)
  dm_error_quark ()
  dm_get_member_raid_sets (name, uuid, major, minor)
  dm_get_raid_set_type (name)
  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)
  fs_can_check (type)
  fs_can_repair (type)
  fs_can_resize (type)
  fs_can_set_label (type)
  fs_check (device)
  fs_clean (device)
  fs_error_quark ()
  fs_ext2_check (device, extra)
  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_wipe (device)
  fs_ext3_check (device, extra)
  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_wipe (device)
  fs_ext4_check (device, extra)
  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_wipe (device)
  fs_freeze (mountpoint)
  fs_get_fstype (device)
  fs_get_mountpoint (device)
  fs_is_mountpoint (path)
  fs_is_tech_avail (tech, mode)
  fs_mount (device, mountpoint, fstype, options, extra)
  fs_ntfs_check (device)
  fs_ntfs_get_info (device)
  fs_ntfs_mkfs (device, extra)
  fs_ntfs_repair (device)
  fs_ntfs_resize (device, new_size)
  fs_ntfs_set_label (device, label)
  fs_ntfs_wipe (device)
  fs_repair (device)
  fs_resize (device, new_size)
  fs_set_label (device, label)
  fs_unfreeze (mountpoint)
  fs_unmount (spec, lazy, force, extra)
  fs_vfat_check (device, extra)
  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_wipe (device)
  fs_wipe (device, all)
  fs_wipe_force (device, all, force)
  fs_xfs_check (device)
  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_wipe (device)
  get_available_plugin_names ()
  get_plugin_name (plugin)
  get_plugin_soname (plugin)
  init (require_plugins, log_func)
  is_initialized ()
  is_plugin_available (plugin)
  kbd_bcache_attach (c_set_uuid, bcache_device)
  kbd_bcache_create (backing_device, cache_device, extra)
  kbd_bcache_destroy (bcache_device)
  kbd_bcache_detach (bcache_device)
  kbd_bcache_get_backing_device (bcache_device)
  kbd_bcache_get_cache_device (bcache_device)
  kbd_bcache_get_mode (bcache_device)
  kbd_bcache_get_mode_from_str (mode_str)
  kbd_bcache_get_mode_str (mode)
  kbd_bcache_set_mode (bcache_device, mode)
  kbd_bcache_status (bcache_device)
  kbd_error_quark ()
  kbd_is_tech_avail (tech, mode)
  kbd_zram_add_device (size, nstreams)
  kbd_zram_create_devices (num_devices, sizes, nstreams)
  kbd_zram_destroy_devices ()
  kbd_zram_get_stats (device)
  kbd_zram_remove_device (device)
  loop_error_quark ()
  loop_get_autoclear (loop)
  loop_get_backing_file (dev_name)
  loop_get_loop_name (file)
  loop_is_tech_avail (tech, mode)
  loop_set_autoclear (loop, autoclear)
  loop_setup (file, offset, size, read_only, part_scan)
  loop_setup_from_fd (fd, offset, size, read_only, part_scan)
  loop_teardown (loop)
  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_data_lv_name (vg_name, lv_name)
  lvm_error_quark ()
  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, 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_lvorigin (vg_name, lv_name)
  lvm_lvremove (vg_name, lv_name, force, extra)
  lvm_lvrename (vg_name, lv_name, new_name, extra)
  lvm_lvresize (vg_name, lv_name, size, extra)
  lvm_lvs (vg_name)
  lvm_lvsnapshotcreate (vg_name, origin_name, snapshot_name, size, extra)
  lvm_lvsnapshotmerge (vg_name, snapshot_name, extra)
  lvm_metadata_lv_name (vg_name, lv_name)
  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_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_vgreduce (vg_name, device, extra)
  lvm_vgremove (vg_name, extra)
  lvm_vgrename (old_vg_name, new_vg_name, extra)
  lvm_vgs ()
  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_namepace_get_supported_sector_sizes (mode)
  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_info (namespace, extra)
  nvdimm_namespace_reconfigure (namespace, mode, force, extra)
  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_flag_str (flag)
  part_get_part_by_pos (disk, position)
  part_get_part_id (disk, part)
  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_disk_flag (disk, flag, state)
  part_set_part_flag (disk, part, flag, state)
  part_set_part_flags (disk, part, flags)
  part_set_part_id (disk, part, part_id)
  part_set_part_name (disk, part, name)
  part_set_part_type (disk, part, type_guid)
  reinit (require_plugins, reload, log_func)
  swap_error_quark ()
  swap_is_tech_avail (tech, mode)
  swap_mkswap (device, label, extra)
  swap_set_label (device, label)
  swap_swapoff (device)
  swap_swapon (device, priority)
  swap_swapstatus (device)
  switch_init_checks (enable)
  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_get_device_symlinks (dev_spec)
  utils_get_linux_version ()
  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_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_unload_kernel_module (module_name)
  utils_version_cmp (ver_string1, ver_string2)
  vdo_activate (name, extra)
  vdo_change_write_policy (name, write_policy, extra)
  vdo_create (name, backing_device, logical_size, index_memory, compression, deduplication, write_policy, extra)
  vdo_deactivate (name, extra)
  vdo_disable_compression (name, extra)
  vdo_disable_deduplication (name, extra)
  vdo_enable_compression (name, extra)
  vdo_enable_deduplication (name, extra)
  vdo_error_quark ()
  vdo_get_stats (name)
  vdo_get_stats_full (name)
  vdo_get_write_policy_from_str (policy_str)
  vdo_get_write_policy_str (policy)
  vdo_grow_logical (name, size, extra)
  vdo_grow_physical (name, extra)
  vdo_info (name)
  vdo_is_tech_avail (tech, mode)
  vdo_remove (name, force, extra)
  vdo_start (name, rebuild, extra)
  vdo_stop (name, force, extra)

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, extra)
Parameters:
  • mountpoint (str) – a mountpoint of the btrfs filesystem to change label of
  • label (str) – new label for the filesystem
  • extra ([BlockDev.ExtraArg] or None) – extra options for the volume creation (right now passed to the ‘btrfs’ utility)
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 avaible – 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_open(device, name, pass_data, read_only)
Parameters:
  • device (str) – the device to open
  • name (str) – name for the BITLK device
  • pass_data (bytes) – a passphrase for the BITLK volume (may contain arbitrary binary data)
  • 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

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) – 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 passphrase for the device or None
Raises:

GLib.Error

Returns:

whether the ecrow data was successfully created for device or not

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

Return type:

bool

BlockDev.crypto_generate_backup_passphrase()
Raises:GLib.Error
Returns:A newly generated %BD_CRYPTO_BACKUP_PASSPHRASE_LENGTH-long passphrase.

See %BD_CRYPTO_BACKUP_PASSPHRASE_CHARSET for the definition of the charset used for the passphrase.

Tech category: always available

Return type:str
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_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_luks_add_key(device, pass_, key_file, npass, nkey_file)
Parameters:
  • device (str) – device to add new key to
  • pass (str or None) – passphrase for the device or None
  • key_file (str or None) – key file for the device or None
  • npass (str or None) – passphrase to add to device or None
  • nkey_file (str or None) – key file to add to device or None
Raises:

GLib.Error

Returns:

whether the npass or nkey_file was successfully added to device or not

One of pass, key_file has to be != None and the same applies to npass, nkey_file.

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

Return type:

bool

BlockDev.crypto_luks_add_key_blob(device, pass_data, npass_data)
Parameters:
  • device (str) – device to add new key to
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data)
  • npass_data (bytes) – a new passphrase for the new LUKS device (may contain arbitrary binary data)
Raises:

GLib.Error

Returns:

whether the npass_data was successfully added to device or not

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

Return type:

bool

BlockDev.crypto_luks_change_key(device, pass_, npass)
Parameters:
  • device (str) – device to change key of
  • pass (str) – old passphrase
  • npass (str) – new passphrase
Raises:

GLib.Error

Returns:

whether the key was successfully changed or not

No support for changing key files (yet).

Tech category: BlockDev.CryptoTech.LUKS-BlockDev.CryptoTechMode.ADD_KEY&:obj:BlockDev.CryptoTechMode.REMOVE_KEY

Return type:

bool

BlockDev.crypto_luks_change_key_blob(device, pass_data, npass_data)
Parameters:
  • device (str) – device to change key of
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data)
  • npass_data (bytes) – a new passphrase for the new LUKS device (may contain arbitrary binary data)
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

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, passphrase, key_file, min_entropy)
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
  • passphrase (str or None) – a passphrase for the new LUKS device or None if not requested
  • key_file (str or None) – a key file for the new LUKS device or None if not requested
  • min_entropy (int) – minimum random data entropy (in bits) required to format device as LUKS
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).

BlockDev.crypto_luks_format_blob(device, cipher, key_size, pass_data, min_entropy)
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
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data)
  • min_entropy (int) – minimum random data entropy (in bits) required to format device as LUKS
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).

BlockDev.crypto_luks_format_luks2(device, cipher, key_size, passphrase, key_file, 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
  • passphrase (str or None) – a passphrase for the new LUKS device or None if not requested
  • key_file (str or None) – a key file for the new LUKS device or None if not requested
  • 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.LUKS2-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).

Either passhphrase or key_file has to be != None.

Using this function with luks_version set to BlockDev.CryptoLUKSVersion.LUKS1 and extra to None is the same as calling BlockDev.crypto_luks_format.

BlockDev.crypto_luks_format_luks2_blob(device, cipher, key_size, pass_data, 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
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data)
  • 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.LUKS2-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).

Using this function with luks_version set to BlockDev.CryptoLUKSVersion.LUKS1 and extra to None is the same as calling BlockDev.crypto_luks_format_blob.

BlockDev.crypto_luks_get_metadata_size(device)
Parameters:device (str) – the queried device
Raises:GLib.Error
Returns:luks device metadata size of the device or 0 if failed to determine (error is populated with the error in such cases)

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

Return type:int
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(luks_device)
Parameters:luks_device (str) – a device to get information about
Raises:GLib.Error
Returns:information about the luks_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, passphrase, key_file, read_only)
Parameters:
  • device (str) – the device to open
  • name (str) – name for the LUKS device
  • passphrase (str or None) – passphrase to open the device or None
  • key_file (str or None) – key file path to use for opening the device or None
  • 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

One of passphrase, key_file has to be != None.

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

Return type:

bool

BlockDev.crypto_luks_open_blob(device, name, pass_data, read_only)
Parameters:
  • device (str) – the device to open
  • name (str) – name for the LUKS device
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data)
  • 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

Return type:

bool

BlockDev.crypto_luks_remove_key(device, pass_, key_file)
Parameters:
  • device (str) – device to add new key to
  • pass (str or None) – passphrase for the device or None
  • key_file (str or None) – key file for the device or None
Raises:

GLib.Error

Returns:

whether the key was successfully removed or not

Either pass or key_file has to be != None.

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

Return type:

bool

BlockDev.crypto_luks_remove_key_blob(device, pass_data)
Parameters:
  • device (str) – device to add new key to
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data) to remove
Raises:

GLib.Error

Returns:

whether the key was successfully removed or not

Either pass or key_file has to be != None.

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

Return type:

bool

BlockDev.crypto_luks_resize(luks_device, size)
Parameters:
  • luks_device (str) – opened LUKS device to resize
  • size (int) – requested size in sectors or 0 to adapt to the backing device
Raises:

GLib.Error

Returns:

whether the luks_device was successfully resized or not

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

Return type:

bool

You need to specify passphrase when resizing LUKS 2 devices that don’t have verified key loaded in kernel. If you don’t specify a passphrase, resize will fail with BlockDev.CryptoError.RESIZE_PERM. Use BlockDev.crypto_luks_resize_luks2 or BlockDev.crypto_luks_resize_luks2_blob for these devices.

BlockDev.crypto_luks_resize_luks2(luks_device, size, passphrase, key_file)
Parameters:
  • luks_device (str) – opened LUKS device to resize
  • size (int) – requested size in sectors or 0 to adapt to the backing device
  • passphrase (str or None) – passphrase to resize the luks_device or None
  • key_file (str or None) – key file path to use for resizinh the luks_device or None
Raises:

GLib.Error

Returns:

whether the luks_device was successfully resized or not

You need to specify either passphrase or keyfile for LUKS 2 devices that don’t have verified key loaded in kernel. For LUKS 1 devices you can set both passphrase and keyfile to None to achieve the same as calling BlockDev.crypto_luks_resize.

Tech category: BlockDev.CryptoTech.LUKS2-BlockDev.CryptoTechMode.RESIZE

Return type:

bool

BlockDev.crypto_luks_resize_luks2_blob(luks_device, size, pass_data)
Parameters:
  • luks_device (str) – opened LUKS device to resize
  • size (int) – requested size in sectors or 0 to adapt to the backing device
  • pass_data (bytes) – a passphrase for the new LUKS device (may contain arbitrary binary data)
Raises:

GLib.Error

Returns:

whether the luks_device was successfully resized or not

You need to specify pass_data for LUKS 2 devices that don’t have verified key loaded in kernel.

Tech category: BlockDev.CryptoTech.LUKS2-BlockDev.CryptoTechMode.RESIZE

Return type:

bool

BlockDev.crypto_luks_resume(luks_device, passphrase, key_file)
Parameters:
  • luks_device (str) – LUKS device to resume
  • passphrase (str or None) – passphrase to resume the device or None
  • key_file (str or None) – key file path to use for resuming the device or None
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

BlockDev.crypto_luks_resume_blob(luks_device, pass_data)
Parameters:
  • luks_device (str) – LUKS device to resume
  • pass_data (bytes) – a passphrase for the LUKS device (may contain arbitrary binary data)
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

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_uuid(device)
Parameters:device (str) – the queried device
Raises:GLib.Error
Returns:UUID of the device 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_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, pass_data, read_only)
Parameters:
  • device (str) – the device to open
  • name (str) – name for the TrueCrypt/VeraCrypt device
  • pass_data (bytes) – a passphrase for the TrueCrypt/VeraCrypt volume (may contain arbitrary binary data)
  • 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

BlockDev.crypto_tc_open_full(device, name, pass_data, keyfiles, hidden, system, veracrypt, veracrypt_pim, read_only)
Parameters:
  • device (str) – the device to open
  • name (str) – name for the TrueCrypt/VeraCrypt device
  • pass_data (bytes) – a passphrase for the TrueCrypt/VeraCrypt volume (may contain arbitrary binary data)
  • 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
  • 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

BlockDev.dm_activate_raid_set(name)
Parameters:name (str) – name of the DM RAID set to activate
Raises:GLib.Error
Returns:whether the RAID set name was successfully activate or not

Tech category: BlockDev.DMTech.RAID-BlockDev.DMTechMode.CREATE_ACTIVATE

Return type:bool
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.MAP-BlockDev.DMTechMode.CREATE_ACTIVATE

Return type:

bool

BlockDev.dm_deactivate_raid_set(name)
Parameters:name (str) – name of the DM RAID set to deactivate
Raises:GLib.Error
Returns:whether the RAID set name was successfully deactivate or not

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

Return type:bool
BlockDev.dm_error_quark()
Return type:int
BlockDev.dm_get_member_raid_sets(name, uuid, major, minor)
Parameters:
  • name (str or None) – name of the member
  • uuid (str or None) – uuid of the member
  • major (int) – major number of the device or -1 if not specified
  • minor (int) – minor number of the device or -1 if not specified
Raises:

GLib.Error

Returns:

list of names of the RAID sets related to the member or None in case of error

One of name, uuid or major:minor has to be given.

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

Return type:

[str]

BlockDev.dm_get_raid_set_type(name)
Parameters:name (str) – name of the DM RAID set to get the type of
Raises:GLib.Error
Returns:string representation of the name RAID set’s type

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

Return type:str
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.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 avaible – 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.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.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.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.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.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_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_check(device)
Parameters:device (str) – the device the file system of which to check
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. 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.

BlockDev.fs_clean(device)
Parameters:device (str) – the device to clean
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_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_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_wipe(device)
Parameters:device (str) – the device to wipe an ext2 signature from
Raises:GLib.Error
Returns:whether an ext2 signature was successfully wiped from the device or not

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

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_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_wipe(device)
Parameters:device (str) – the device to wipe an ext3 signature from
Raises:GLib.Error
Returns:whether an ext3 signature was successfully wiped from the device or not

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

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_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_wipe(device)
Parameters:device (str) – the device to wipe an ext4 signature from
Raises:GLib.Error
Returns:whether an ext4 signature was successfully wiped from the device or not

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

Return type:bool
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_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_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_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 unmount currently only ‘run_as_uid’ and ‘run_as_gid’ are supported value must be a valid non zero uid (gid)
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_ntfs_check(device)
Parameters:device (str) – the device containing the file system to check
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_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)
Parameters:device (str) – the device containing the file system to repair
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_wipe(device)
Parameters:device (str) – the device to wipe an ntfs signature from
Raises:GLib.Error
Returns:whether an ntfs signature was successfully wiped from the device or not

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

Return type:bool
BlockDev.fs_repair(device)
Parameters:device (str) – the device the file system of which to repair
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.

BlockDev.fs_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.GENERIC-BlockDev.FSTechMode.RESIZE

Return type:

bool

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

GLib.Error

Returns:

whether the file system on device was successfully relabled 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_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)
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_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

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_wipe(device)
Parameters:device (str) – the device to wipe an vfat signature from
Raises:GLib.Error
Returns:whether an vfat signature was successfully wiped from the device or not

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

Return type:bool
BlockDev.fs_wipe(device, all)
Parameters:
  • device (str) – the device to wipe signatures from
  • all (bool) – whether to wipe all (True) signatures or just the first (False) one
Raises:

GLib.Error

Returns:

whether signatures were successfully wiped on device or not

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

Return type:

bool

Note: This function will wipe signatures on a mounted device without asking. Use BlockDev.fs_wipe_force if you want to control this behaviour manually.

BlockDev.fs_wipe_force(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 force wipe even if the filesystem is mounted
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)
Parameters:device (str) – the device containing the file system to check
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_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_wipe(device)
Parameters:device (str) – the device to wipe an xfs signature from
Raises:GLib.Error
Returns:whether an xfs signature was successfully wiped from the device or not

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

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.2"};

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.kbd_bcache_attach(c_set_uuid, bcache_device)
Parameters:
  • c_set_uuid (str) – cache set UUID of the cache to attach
  • bcache_device (str) – bcache device to attach c_set_uuid cache to
Raises:

GLib.Error

Returns:

whether the c_set_uuid cache was successfully attached to bcache_device or not

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.MODIFY

Return type:

bool

BlockDev.kbd_bcache_create(backing_device, cache_device, extra)
Parameters:
  • backing_device (str) – backing (slow) device of the cache
  • cache_device (str) – cache (fast) device of the cache
  • extra ([BlockDev.ExtraArg] or None) – extra options for the creation (right now passed to the ‘make-bcache’ utility)
Raises:

GLib.Error

Returns:

whether the bcache device was successfully created or not

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.CREATE

bcache_device:place to store the name of the new bcache device (if any)

Return type:

(bool, bcache_device: str)

BlockDev.kbd_bcache_destroy(bcache_device)
Parameters:bcache_device (str) – bcache device to destroy
Raises:GLib.Error
Returns:whether the bcache device bcache_device was successfully destroyed or not

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.DESTROY

Return type:bool
BlockDev.kbd_bcache_detach(bcache_device)
Parameters:bcache_device (str) – bcache device to detach the cache from
Raises:GLib.Error
Returns:whether the bcache device bcache_device was successfully destroyed or not

Note: Flushes the cache first.

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.MODIFY

c_set_uuid:cache set UUID of the detached cache
Return type:(bool, c_set_uuid: str)
BlockDev.kbd_bcache_get_backing_device(bcache_device)
Parameters:bcache_device (str) – Bcache device to get the backing device for
Raises:GLib.Error
Returns:name of the backing device of the bcache_device or None if failed to determine (error is populated)

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.QUERY

Return type:str
BlockDev.kbd_bcache_get_cache_device(bcache_device)
Parameters:bcache_device (str) – Bcache device to get the cache device for
Raises:GLib.Error
Returns:name of the cache device of the bcache_device or None if failed to determine (error is populated)

Note: returns the name of the first cache device of bcache_device (in case there are more)

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.QUERY

Return type:str
BlockDev.kbd_bcache_get_mode(bcache_device)
Parameters:bcache_device (str) – device to get mode of
Raises:GLib.Error
Returns:current mode of the bcache_device

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.QUERY

Return type:BlockDev.KBDBcacheMode
BlockDev.kbd_bcache_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.KBDBcacheMode.UNKNOWN in case of no match
Return type:BlockDev.KBDBcacheMode
BlockDev.kbd_bcache_get_mode_str(mode)
Parameters:mode (BlockDev.KBDBcacheMode) – 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.kbd_bcache_set_mode(bcache_device, mode)
Parameters:
Raises:

GLib.Error

Returns:

whether the mode was successfully set or not

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.MODIFY

Return type:

bool

BlockDev.kbd_bcache_status(bcache_device)
Parameters:bcache_device (str) – bcache device to get status for
Raises:GLib.Error
Returns:status of the bcache_device or None in case of error (error is set)

Tech category: BlockDev.KBDTech.BCACHE-BlockDev.KBDTechMode.QUERY

Return type:BlockDev.KBDBcacheStats
BlockDev.kbd_error_quark()
Return type:int
BlockDev.kbd_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.kbd_zram_add_device(size, nstreams)
Parameters:
  • size (int) – size of the zRAM device to add
  • nstreams (int) – number of streams to use for the new device (or 0 to use the defaults)
Raises:

GLib.Error

Returns:

whether a new zRAM device was added or not

Tech category: BlockDev.KBDTech.ZRAM-BlockDev.KBDTechMode.MODIFY

device:place to store the name of the newly added device

Return type:

(bool, device: str)

BlockDev.kbd_zram_create_devices(num_devices, sizes, nstreams)
Parameters:
  • num_devices (int) – number of devices to create
  • sizes ([int]) – requested sizes (in bytes) for created zRAM devices
  • nstreams ([int] or None) – numbers of streams for created zRAM devices
Raises:

GLib.Error

Returns:

whether num_devices zRAM devices were successfully created or not

**Lengths of size and nstreams (if given) have to be >= num_devices!**

Tech category: BlockDev.KBDTech.ZRAM-BlockDev.KBDTechMode.CREATE

Return type:

bool

BlockDev.kbd_zram_destroy_devices()
Raises:GLib.Error
Returns:whether zRAM devices were successfully destroyed or not

The only way how to destroy zRAM device right now is to unload the ‘zram’ module and thus destroy all of them. That’s why this function doesn’t allow specification of which devices should be destroyed.

Tech category: BlockDev.KBDTech.ZRAM-BlockDev.KBDTechMode.DESTROY

Return type:bool
BlockDev.kbd_zram_get_stats(device)
Parameters:device (str) – zRAM device to get stats for
Raises:GLib.Error
Returns:statistics for the zRAM device

Tech category: BlockDev.KBDTech.ZRAM-BlockDev.KBDTechMode.QUERY

Return type:BlockDev.KBDZramStats
BlockDev.kbd_zram_remove_device(device)
Parameters:device (str) – zRAM device to remove
Raises:GLib.Error
Returns:whether the device was successfully removed or not

Tech category: BlockDev.KBDTech.ZRAM-BlockDev.KBDTechMode.MODIFY

Return type:bool
BlockDev.loop_error_quark()
Return type:int
BlockDev.loop_get_autoclear(loop)
Parameters:loop (str) – path or name of the loop device
Raises:GLib.Error
Returns:whether the autoclear flag is set on the loop device or not (if False, error may be set)

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

Return type:bool
BlockDev.loop_get_backing_file(dev_name)
Parameters:dev_name (str) – name of the loop device to get backing file for (e.g. “loop0”)
Raises:GLib.Error
Returns:path of the device’s backing file or None if none is found

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

Return type:str
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_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)
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
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)
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
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_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 attache 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

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_data_lv_name(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 name of the (internal) data LV of the vg_name/lv_name LV

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

Return type:

str

BlockDev.lvm_error_quark()
Return type:int
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 (BlockDev.LVM_DEFAULT_CHUNK_SIZE)
  • n_snapshots (int) – number of snapshots that will be created in the pool
Raises:

GLib.Error

Returns:

recommended size of the metadata space for the specified pool or 0 in case of error

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

Return type:

int

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 avaible – 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, 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
  • 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_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_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_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 fo 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_metadata_lv_name(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 name of the (internal) metadata LV of the vg_name/lv_name LV

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

Return type:

str

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 underlaying 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_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 fo 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: %BD_LVM_TECH_POOL-BlockDev.LVMTechMode.CREATE

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) – name of the to-be-created VDO pool LV
  • 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_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.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:cannonicalized 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 (bool) – whether to create an internal bitmap on the device or not
  • 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 avaible – 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_namepace_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_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_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:
Raises:

GLib.Error

Returns:

whether namespace was successfully reconfigured or not

Return type:

bool

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_flag_str(flag)
Parameters:flag (BlockDev.PartFlag) – flag to get string representation for
Raises:GLib.Error
Returns:string representation of flag

Tech category: always available

Return type:str
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_id(disk, part)
Parameters:
  • disk (str) – device the partition belongs to
  • part (str) – partition the should be set for
Raises:

GLib.Error

Return type:

str

Returns (transfer full): partition id type or None in case of error

Tech category: BlockDev.PartTechMode.QUERY_PART + the tech according to the partition table type

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 paritition
  • 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_disk_flag(disk, flag, state)
Parameters:
Raises:

GLib.Error

Returns:

whether the flag flag was successfully set on the disk or not

Tech category: BlockDev.PartTechMode.MODIFY_TABLE + the tech according to the partition table type

Return type:

bool

BlockDev.part_set_part_flag(disk, part, flag, state)
Parameters:
  • disk (str) – disk the partition belongs to
  • part (str) – partition to set the flag on
  • flag (BlockDev.PartFlag) – flag to set
  • state (bool) – state to set for the flag (True = enabled)
Raises:

GLib.Error

Returns:

whether the flag flag was successfully set on the part partition or not.

Tech category: BlockDev.PartTechMode.MODIFY_PART + the tech according to the partition table type

Return type:

bool

BlockDev.part_set_part_flags(disk, part, flags)
Parameters:
  • disk (str) – disk the partition belongs to
  • part (str) – partition to set the flag on
  • flags (int) – flags to set (mask combined from BlockDev.PartFlag numbers)
Raises:

GLib.Error

Returns:

whether the flags were successfully set on the part partition or not

Note: Unsets all the other flags on the partition. Only GPT-specific flags and the legacy boot flag are supported on GPT partition tables.

Tech category: BlockDev.PartTechMode.MODIFY_PART + the tech according to the partition table type

Return type:

bool

BlockDev.part_set_part_id(disk, part, part_id)
Parameters:
  • disk (str) – device the partition belongs to
  • part (str) – partition the 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.PartTechMode.MODIFY_PART + the tech according to the partition table type

Return type:

bool

BlockDev.part_set_part_name(disk, part, name)
Parameters:
  • disk (str) – device the partition belongs to
  • part (str) – partition the 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 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.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, extra)
Parameters:
  • device (str) – a device to create swap space on
  • label (str or None) – a label 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_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.switch_init_checks(enable)
Parameters:enable (bool) – whether to enable init checks (True) or not (False)
Raises:GLib.Error
Return type:bool

Enables or disables plugins’ init checks based on enable.

Note: The current implementation (un)sets the LIBBLOCKDEV_SKIP_DEP_CHECKS environment variable.

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)

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)

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)

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_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 reset to default
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_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_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’-R [.Z3…[-R]’]]]] where all components are natural numbers!**

Return type:

int

BlockDev.vdo_activate(name, extra)
Parameters:
  • name (str) – name of an existing VDO volume
  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO creation (just passed to VDO as is)
Raises:

GLib.Error

Returns:

whether the VDO volume was successfully activated or not

Tech category: BlockDev.VDOTech.VDO_TECH_VDO-BlockDev.VDOTechMode.ACTIVATE_DEACTIVATE

Return type:

bool

Deprecated since version 2.24: Use LVM-VDO integration instead.

BlockDev.vdo_change_write_policy(name, write_policy, extra)
Parameters:
Raises:

GLib.Error

Returns:

whether the policy was successfully changed or not

Tech category: BlockDev.VDOTech.VDO_TECH_VDO-BlockDev.VDOTechMode.MODIFY

Return type:

bool

Deprecated since version 2.24: Use LVM-VDO integration instead.

BlockDev.vdo_create(name, backing_device, logical_size, index_memory, compression, deduplication, write_policy, extra)
Parameters:
  • name (str) – name for the VDO volume
  • backing_device (str) – device to use for VDO storage
  • logical_size (int) – logical VDO volume size or 0 for default (size of backing_device)
  • index_memory (int) – amount of index memory or 0 for default; note that only some sizes are valid here (0.25, 0.5 and 0.75 GB and integer multiples of 1 GB) invalid sizes will be rounded DOWN to nearest GB (or one of the allowed decimal values)
  • compression (bool) – whether to enable compression or not
  • deduplication (bool) – whether to enable deduplication or not
  • write_policy (BlockDev.VDOWritePolicy) – write policy for the volume
  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO creation (just passed to VDO as is)
Raises:

GLib.Error

Returns:

whether the VDO volume was successfully created or not

Tech category: BlockDev.VDOTech.VDO_TECH_VDO-BlockDev.VDOTechMode.CREATE

Return type:

bool

Deprecated since version 2.24: Use LVM-VDO integration instead.

BlockDev.vdo_deactivate(name, extra)
Parameters:
  • name (str) – name of an existing VDO volume
  • extra ([BlockDev.ExtraArg] or None) – extra options for the VDO creation (just passed to VDO as is)
Raises:

GLib.Error

Returns:

whether the VDO volume was successfully deactivated or not

Tech category: BlockDev.VDOTech.VDO_TECH_VDO-BlockDev.VDOTechMode.ACTIVATE_DEACTIVATE

Return type:

bool

Deprecated since version 2.24: Use LVM-VDO integration instead.

Bloc