statblk
Gather disk and partition information for block devices and print it as a table or JSON.
Supports Linux and macOS.
Install
From PyPI:
pip install statblk
From a clone of this repository:
pip install .
Optional shell tab completion:
pip install 'statblk[completion]'
Requires Python 3.6+ and the multiCMD package (>= 1.47).
Quick start
statblk
statblk -j # JSON output (rows, header first)
statblk -J # JSON objects with numeric sizes/rates
statblk -o NAME,SIZE,MOUNTPOINT
statblk sda nvme # filter rows matching sda or nvme
statblk 2 # refresh every 2 seconds (watch mode)
Output columns
By default all columns are shown:
| Column | Description |
|---|---|
NAME |
Block device name (device-mapper devices show their /dev/mapper name, e.g. pve-root) |
FSTYPE |
Filesystem type |
SIZE |
Device or filesystem size |
FSUSE% |
Filesystem space used (mounted entries); TIMEOUT for a mount that didn't answer (e.g. dead NFS server) |
MOUNTPOINT |
Mount path |
SMART |
SMART health (OK, DENIED, TIMEOUT, etc.) |
LABEL |
Volume label |
UUID |
Filesystem UUID |
MODEL |
Drive model (from udev via lsblk, sysfs fallback) |
SERIAL |
Drive serial (from udev via lsblk, sysfs fallback) |
DISCARD |
TRIM / discard support |
READ |
Current read throughput |
WRITE |
Current write throughput |
Use -o / --output to select columns (comma-separated) or -x / --exclude to omit columns.
Options
Output format
| Flag | Description |
|---|---|
-j, --json |
Print JSON instead of a table (list of rows, header first; values as displayed) |
-J, --json_objects |
Print JSON as a list of objects: SIZE/READ/WRITE in bytes and FSUSE% as an integer (null when unavailable) |
-b, --bytes |
Print sizes and throughput as raw byte counts |
-H, --si |
Use powers of 1000 (SI) instead of 1024 for sizes |
-R, --full |
Do not truncate long values to terminal width |
-o, --output |
Columns to include (default: all) |
-x, --exclude |
Columns to omit |
Filtering
| Flag | Description |
|---|---|
filter_patterns … |
Show rows matching any pattern (regex) |
-D, --match_devname_only |
Apply patterns to device names only (kernel name or /dev/mapper name) |
-v, --invert_match |
Invert pattern match (with no patterns, prints only the header) |
-F, -fo, --formated_only |
Only entries with a filesystem type |
-M, -mo, --mounted_only |
Only mounted devices |
-B, -bo, --best_only |
Shortest mount point per device |
-A, -ao, --active_only |
Only devices with read/write activity |
-P, --pseudo |
Include pseudo filesystems (tmpfs, nfs, cifs, …) |
--show_zero_size_devices |
Include zero-size devices |
Runtime
| Flag | Description |
|---|---|
-t, --timeout |
Time budget per refresh in seconds for lsblk, smartctl and statvfs (default: 2) |
-w, --watch SECONDS |
Repeat output every SECONDS (watch mode) |
--sudo |
Run external commands via sudo (needed for SMART on many systems). smartctl is also looked up in /usr/sbin, /sbin, /usr/local/sbin when it isn't on PATH |
--debug |
Print suppressed exceptions to stderr |
-V, --version |
Show version and exit |
Watch mode
Prefer -w / --watch. A trailing integer positional still works the same as before:
statblk -w 5 # update every 5 seconds
statblk 5 # same (trailing integer)
statblk sda 3 # filter to sda, refresh every 3 seconds
statblk -w 3 sda # same with explicit flag (flag wins if both are given)
After the first refresh, --active_only is enabled automatically on Linux so only busy devices are shown (not on macOS, where throughput isn't available). Each refresh re-reads mounts, labels, UUIDs, sizes, and per-drive sysfs info such as model/serial, so hot-swapped drives show up correctly (throughput iterators stay live across refreshes). Press Ctrl-C to stop (exit status 130).
If a filter pattern looks like a number, append 0 so it is not treated as the refresh interval (or use -w and keep the number as a filter):
statblk nvme0 0 # match nvme0, single run (no watch)
statblk -w 0 nvme0 # same via flag
Platform notes
Linux
Uses sysfs, /proc/self/mountinfo, lsblk, and optionally smartctl.
- SMART requires
smartctl(smartmontools). Use--sudoif permission is denied. It only runs against hardware-backed disks (not loop, dm, md, zram, nbd). Use--debugto see why the column is empty. - autofs trigger mounts are ignored (stat-ing them would trigger the automount); the real filesystem appears once mounted.
- READ / WRITE throughput comes from
/sys/class/block/*/stat(always 512-byte sector units). - On a single-shot run (and the first row of watch mode), READ/WRITE are a lifetime busy-time average (bytes / time spent in I/O since boot). In watch mode, later refreshes are interval rates over the sleep period (Δbytes / wall clock).
macOS
Uses diskutil and mount. Throughput columns are always zero (no per-device sysfs stats). APFS snapshot nodes such as the sealed system volume (disk3s1s1 on /) are listed.
Development
Install test deps:
pip install -r requirements-dev.txt
Run unit tests (default; live excluded) and embedded doctests:
pytest
python -m doctest statblk.py -v
python statblk.py --doctest
Optional live checks:
pytest -m live # soft smoke on this host
pytest -m live_strict # compare FSUSE% and names to df/lsblk
License
GPLv3+ — Yufei Pan (pan@zopyr.us)
Project home: github.com/yufei-pan/statblk
Metadata
Release files for statblk 1.44
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| statblk-1.44.tar.gz | 35.7 kB | Without provenance | Details for statblk-1.44.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| statblk-1.44-py3-none-any.whl | Python 3 | none | any | Details for statblk-1.44-py3-none-any.whl |
Total release size: 61.7 kB
Release files / statblk-1.44.tar.gz
| Download URL | statblk-1.44.tar.gz |
|---|---|
| Size | 35.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3884003e224e58a88cc390338628e73b2ca514315086236ac4ac8cb05b5e6028
|
|
BLAKE2b-256 checksum How to use checksums |
c5596e20c33733af3457299ad61043029e70d121654f151aacb8805f1e12f62b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / statblk-1.44-py3-none-any.whl
| Download URL | statblk-1.44-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d5aa9c39a48aaeb0017c319fe8f2cdbc01d6c759855f58bdd999ab692b924509
|
|
BLAKE2b-256 checksum How to use checksums |
79b0ebcf3da74e44512310c140788a1c99afe5cf29b1f0bfdb96f1f40617c5be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for statblk 1.44
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.