LinuxCommandLibrary

blkpr

Display or modify block device attributes

TLDR

Register (command) a new reservation with a given key on a given device

$ blkpr [[-c|--command]] register [[-k|--key]] [reservation_key] [path/to/device]
copy

Set the type of an existing reservation to exclusive access
$ blkpr [[-c|--command]] reserve [[-k|--key]] [reservation_key] [[-t|--type]] exclusive-access [path/to/device]
copy

Preempt the existing reservation with a given key and replace it with a new reservation
$ blkpr [[-c|--command]] preempt [[-K|--oldkey]] [old_key] [[-k|--key]] [new_key] [[-t|--type]] write-exclusive [path/to/device]
copy

Release a reservation with a given key and type on a given device
$ blkpr [[-c|--command]] release [[-k|--key]] [reservation_key] [[-t|--type]] [reservation_type] [path/to/device]
copy

Clear all reservations from a given device
$ blkpr [[-c|--command]] clear [[-k|--key]] [key] [path/to/device]
copy

SYNOPSIS

blkpr [options] <device>

PARAMETERS

-h, --help
    Display help text and exit.

-V, --version
    Display version information and exit.

-o FORMAT, --output=FORMAT
    Select output format: native (default) or json.

-b, --bytes
    Print sizes in bytes rather than human-readable format.

DESCRIPTION

The blkpr command displays key parameters of Linux block devices, such as rotational status, I/O queue depth, read-ahead size, and discard capabilities. It queries the device's /sys/block directory for runtime and static properties, helping administrators tune storage performance, diagnose hardware issues, or script automation for NVMe, SSDs, or HDDs.

Useful in environments with diverse storage backends, blkpr provides concise output for parameters like nomerges, rq_affinity, and iothread, aiding in scheduler selection (e.g., mq-deadline, none) and optimizing workloads. Output formats include human-readable native or structured JSON, making it ideal for parsing in tools like Ansible or monitoring scripts.

Run on devices like /dev/nvme0n1 or /dev/sda to inspect settings without unloading drivers.

CAVEATS

Requires read access to /sys/block/<dev>/queue/; may need root privileges for some devices. Does not support multiple devices.

EXAMPLE OUTPUT

blkpr /dev/sda
rotational: 1
queue_depth: 32
read_ahead_kb: 128
nr_requests: 128

JSON USAGE

blkpr -o json /dev/nvme0n1 for parseable output in monitoring scripts.

HISTORY

Introduced in util-linux 2.32 (2017) to consolidate block device inspection tools, evolving from older sysfs queries.

SEE ALSO

lsblk(8), blockdev(8), blkid(8)

Copied to clipboard