salt.modules.disk

Module for managing disks and blockdevices

salt.modules.disk.blkid(device=None, token=None)

Return block device attributes: UUID, LABEL, etc. This function only works on systems where blkid is available.

device

Device name from the system

token

Any valid token used for the search

CLI Example:

salt '*' disk.blkid
salt '*' disk.blkid /dev/sda
salt '*' disk.blkid token='UUID=6a38ee5-7235-44e7-8b22-816a403bad5d'
salt '*' disk.blkid token='TYPE=ext4'
salt.modules.disk.dump(device, args=None)

Return all contents of dumpe2fs for a specified device

device

The device path to dump.

args

A list of attributes to return. Returns all by default.

CLI Example:

salt '*' disk.dump /dev/sda1
salt.modules.disk.format_(device, fs_type='ext4', inode_size=None, lazy_itable_init=None, fat=None, force=False)

Format a filesystem onto a device

New in version 2016.11.0.

device

The device in which to create the new filesystem

fs_type

The type of filesystem to create

inode_size

Size of the inodes

This option is only enabled for ext and xfs filesystems

lazy_itable_init

If enabled and the uninit_bg feature is enabled, the inode table will not be fully initialized by mke2fs. This speeds up filesystem initialization noticeably, but it requires the kernel to finish initializing the filesystem in the background when the filesystem is first mounted. If the option value is omitted, it defaults to 1 to enable lazy inode table zeroing.

This option is only enabled for ext filesystems

fat

FAT size option. Can be 12, 16 or 32, and can only be used on fat or vfat filesystems.

force

Force mke2fs to create a filesystem, even if the specified device is not a partition on a block special device. This option is only enabled for ext and xfs filesystems

This option is dangerous, use it with caution.

CLI Example:

salt '*' disk.format /dev/sdX1
salt.modules.disk.fstype(device)

Return the filesystem name of the specified device

New in version 2016.11.0.

device

The name of the device

CLI Example:

salt '*' disk.fstype /dev/sdX1
salt.modules.disk.get_fstype_from_path(path)

Return the filesystem type of the underlying device for a specified path.

New in version 3006.0.

path

The path for the function to evaluate.

CLI Example:

salt '*' disk.get_fstype_from_path /root
salt.modules.disk.hdparms(disks, args='aAbBcCdgHiJkMmNnQrRuW')

Retrieve disk parameters.

New in version 2016.3.0.

disks

Single disk or list of disks to query.

args

Sequence of hdparm flags to fetch.

CLI Example:

salt '*' disk.hdparms /dev/sda
salt.modules.disk.hpa(disks, size=None)

Get/set Host Protected Area settings

T13 INCITS 346-2001 (1367D) defines the BEER (Boot Engineering Extension Record) and PARTIES (Protected Area Run Time Interface Extension Services), allowing for a Host Protected Area on a disk.

It's often used by OEMS to hide parts of a disk, and for overprovisioning SSD's

Warning

Setting the HPA might clobber your data, be very careful with this on active disks!

New in version 2016.3.0.

CLI Example:

salt '*' disk.hpa /dev/sda
salt '*' disk.hpa /dev/sda 5%
salt '*' disk.hpa /dev/sda 10543256
salt.modules.disk.inodeusage(args=None)

Return inode usage information for volumes mounted on this minion

args

Sequence of flags to pass to the df command.

CLI Example:

salt '*' disk.inodeusage
salt.modules.disk.iostat(interval=1, count=5, disks=None)

Gather and return (averaged) IO stats.

New in version 2016.3.0.

Changed in version 2016.11.4: Added support for AIX

CLI Example:

salt '*' disk.iostat 1 5 disks=sda
salt.modules.disk.percent(args=None)

Return partition information for volumes mounted on this minion

args

Specify a single partition for which to return data.

CLI Example:

salt '*' disk.percent /var
salt.modules.disk.resize2fs(device)

Resizes the filesystem.

CLI Example:

salt '*' disk.resize2fs /dev/sda1
salt.modules.disk.smart_attributes(dev, attributes=None, values=None)

Fetch SMART attributes Providing attributes will deliver only requested attributes Providing values will deliver only requested values for attributes

Default is the Backblaze recommended set (https://www.backblaze.com/blog/hard-drive-smart-stats/): (5,187,188,197,198)

New in version 2016.3.0.

CLI Example:

salt '*' disk.smart_attributes /dev/sda
salt '*' disk.smart_attributes /dev/sda attributes=(5,187,188,197,198)
salt.modules.disk.tune(device, **kwargs)

Set attributes for the specified device

CLI Example:

salt '*' disk.tune /dev/sda1 read-ahead=1024 read-write=True

Valid options are: read-ahead, filesystem-read-ahead, read-only, read-write.

See the blockdev(8) manpage for a more complete description of these options.

salt.modules.disk.usage(args=None)

Return usage information for volumes mounted on this minion

args

Sequence of flags to pass to the df command.

Changed in version 2019.2.0: Default for SunOS changed to 1 kilobyte blocks

CLI Example:

salt '*' disk.usage
salt.modules.disk.wipe(device)

Remove the filesystem information

CLI Example:

salt '*' disk.wipe /dev/sda1