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



Returns the value of used space of the defined partition




Runs utility lsblk using flag --help to retrieve to check for one specific 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.