Format number and unit from KB, MB, GB, TB to MB
parted_print( dev => '/dev/vda'[, unit => 'GB']);
Print partition of device dev in unit unit. By default unit is expressed in MB.
Get partition number by given device partition start and end
Get the first parition number by given device and partition/FS type. e.g. extended, xfs Return -1 when not find
free_space( dev => '/dev/vda', unit => 'MB');
Using utility parted
and passing named arguments dev and unit in which to perform the operation, get all information (start, end, size) about the bigest free space Return a hash containing start, end and size
Get partition by mountpoint, e.g. give /home get /dev/sda3
Get partition table information by giving device
get_partition_table_via_blkid('/dev/vda');
Get partition table information of giving device using blkid (for example, minimal role does not install parted)
Create a new partition by giving device, partition type and partition size part_type (extended|logical|primary)
Remove a partition by given partition name, e.g /dev/sdb5
format_partition($partition, $filesystem [, options => $options] );
Format partition to target filesystem. The optional value $options
is '-f' as default.
Returns the value of the "df -h" output in given column, for a given partition
df_command([partition=>$partition , column=> $column])
Return the value of the defined partition size
get_partition_size($partition)
Returns the value of used space of the defined partition
get_used_partition_space($partition)
is_lsblk_able_to_display_mountpoints();
Runs utility lsblk
using flag -H or --help to check whether it supports the column 'MOUNTPOINTS'.
From version util-linux-systemd-2.37 lsblk include new column MOUNTPOINTS with all the mountpoints including all the subvolumes in a btrfs system and in this case existing column MOUNTPOINT does not contain the primary mountpoint for the partition, the first mounted, instead contains the most recent one mounted. Therefore we need to workaround this issue. Please check bsc#1192996 for further info.
my $json = lsblk_command(output => $output);
Runs utility lsblk
using flag -J to retrieve json and returns decoded json.
Named argument output specifies a comma-separated list of columns selected for the output.
my $validation_test_data = create_lsblk_validation_test_data(
device => $dev, has_mountpoints_col => 1);
Converts test data to test data adapted for validation using lsblk
.
For the device passed converts its test data to corresponding lsblk columns if available in the mapping of this function. Returns the following hash ref structure: { <lsblk_col_name_1> => { test_data_name => <test_data_col_name>, value => <value> } <lsblk_col_name_2> => { ... } };
Named argument device specifies a block device Named argument has_mountpoints_col indicates whether version of lsblk
used contains new MOUNTPOINTS column including all subvolumes mountpoints or not.
$errors .= validate_lsblk(device => $disk, type => 'disk');
Validates test data using lsblk
and returns a summary of all errors found.
device represents the device which is used to get output from lsblk
command. Use common structure in test data for partitioning, for example:
disks: - name: vda table_type: gpt allowed_unpartitioned: 0.00GB partitions: - name: vda1 formatting_options: should_format: 1 filesystem: xfs mounting_options: should_mount: 1 mount_point: / ...
type represents the type of device. Valid values: 'disk' and 'part'; has_mountpoints_col indicates whether version of lsblk
used contains new MOUNTPOINTS column including all subvolumes mountpoints or not.
Returns string with all found errors.
Generate xfstests subtests list This function translate test range to single tests, with xfstests test name format. Input an parameter with list of subtest name, Return a hash of test list. e.g. generate "xfs/001-003,xfs/005" into "{xfs/001 => 1, xfs/002 => 1, xfs/003 => 1, xfs/005 => 1}"