New Tool: lsds – List All Linux Block Devices and Settings in One Place by mfiguiere
2025-05-09
When dealing with disks and I/O things on Linux, you’d regularly run commands like lsblk
, lsscsi
, nvme list
, etc. All of them tend to report a different set of information, so I ended up running multiple commands and correlating their output based on the device name or number.
And then I had to run commands like these, to get extra info about the current OS-level configuration settings for specific disks:
grep . /sys/class/block/sd*/device/queue_depth
grep . /sys/class/block/*/queue/nr_requests
The above commands would show the hardware-advertised device queue depth and the OS block device level (software) queue depth.
I finally had enough and created a single Python program lsds for showing all interesting bits for a disk in one place. The lsds tool does not execute any other commands under the hood, it just reads the relevant info from sysfs /sys/class/blocks/...
directories directly.
See my 0x.tools toolset for more Linux performance & troubleshooting tools.
Here’s an output from my machine with 21 SSDs in it. You may need to scroll right to see the full output:
$ lsds DEVNAME MAJ:MIN SIZE TYPE SCHED ROT MODEL QDEPTH NR_RQ WCACHE nvme0n1 259:4 931.5 GiB NVMeDisk none 0 Samsung SSD 9100 PRO 1TB - 1023 write back nvme10n1 259:21 465.8 GiB NVMeDisk none 0 Samsung SSD 980 PRO 500GB - 1023 write back nvme11n1 259:22 465.8 GiB NVMeDisk none 0 Samsung SSD 980 PRO 500GB - 1023 write back nvme12n1 259:9 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme13n1 259:16 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme14n1 259:8 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme15n1 259:15 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme16n1 259:12 1863.0 GiB NVMeDisk none 0 T-FORCE TM8FF1002T - 1023 write back nvme17n1 259:11 1863.0 GiB NVMeDisk none 0 T-FORCE TM8FF1002T - 1023 write back nvme18n1 259:13 1863.0 GiB NVMeDisk none 0 T-FORCE TM8FF1002T - 1023 write back nvme19n1 259:14 1863.0 GiB NVMeDisk none 0 T-FORCE TM8FF1002T - 1023 write back nvme1n1 259:1 931.5 GiB NVMeDisk none 0 Samsung SSD 9100 PRO 1TB - 1023 write back nvme20n1 259:3 1863.0 GiB NVMeDisk none 0 Samsung SSD 990 PRO 2TB - 1023 write back nvme2n1 259:2 931.5 GiB NVMeDisk none 0 Samsung SSD 9100 PRO 1TB - 1023 write back nvme3n1 259:0 931.5 GiB NVMeDisk none 0 Samsung SSD 9100 PRO 1TB - 1023 write back nvme4n1 259:18 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme5n1 259:23 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme6n1 259:19 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme7n1 259:20 931.5 GiB NVMeDisk none 0 Samsung SSD 980 PRO 1TB - 1023 write back nvme8n1 259:17 1788.5 GiB NVMeDisk none 0 SAMSUNG MZQL21T9HCJR-00A07 - 1023 write through nvme9n1 259:10 1397.3 GiB NVMeDisk none 0 INTEL SSDPE21D015TA - 1023 write through
All the above disks are NVMe SSDs, so the I/O scheduler (SCHED) is “none” and the rotational flag (ROT) is 0.
If you prefer narrower pivoted output, you can use the --pivot
option as you see below. I also added the --verbose
flag to explain where this tool got its information from:
$ lsds -pv DEVNAME NAME VALUE nvme0n1 MAJ:MIN 259:4 /sys/class/block/nvme0n1/dev nvme0n1 SIZE 931.5 GiB /sys/class/block/nvme0n1/size * 512 nvme0n1 TYPE NVMeDisk devname, /sys/class/block/nvme0n1/partition nvme0n1 SCHED none /sys/class/block/nvme0n1/queue/scheduler nvme0n1 ROT 0 /sys/class/block/nvme0n1/queue/rotational nvme0n1 MODEL Samsung SSD 9100 PRO 1TB /sys/class/block/nvme0n1/device/model nvme0n1 QDEPTH - /sys/class/block/nvme0n1/device/queue_depth (N/A for NVMe) nvme0n1 NR_RQ 1023 /sys/class/block/nvme0n1/queue/nr_requests nvme0n1 WCACHE write back /sys/class/block/nvme0n1/queue/write_cache ... nvme9n1 MAJ:MIN 259:10 /sys/class/block/nvme9n1/dev nvme9n1 SIZE 1397.3 GiB /sys/class/block/nvme9n1/size * 512 nvme9n1 TYPE NVMeDisk devname, /sys/class/block/nvme9n1/partition nvme9n1 SCHED none /sys/class/block/nvme9n1/queue/scheduler nvme9n1 ROT 0 /sys/class/block/nvme9n1/queue/rotational nvme9n1 MODEL INTEL SSDPE21D015TA /sys/class/block/nvme9n1/device/model nvme9n1 QDEPTH - /sys/class/block/nvme9n1/device/queue_depth (N/A for NVMe) nvme9n1 NR_RQ 1023 /sys/class/block/nvme9n1/queue/nr_requests nvme9n1 WCACHE write through /sys/class/block/nvme9n1/q
5 Comments
DonHopkins
I always wanted the /dev/zero character device driver, which you can map into memory to clear it, or use as an infinite source of nulls, to use the minor node number as the value that got mapped into memory or produced, so you could make an infinite source of beeps with:
mknod /dev/seven c 1 7
I wonder what would happen if you made a /dev/seven device in your http servers public_html directory? Would it dutifully serve it up?
Better yet, support for utf-8 unicode, so you can make an infinite source of poo emojis.
The "Everything Is A File" philosophy should be taken to its logical conclusion.
bitbang
Very nice, needs option for json/jsonl output.
babuloseo
can we package this for Arch? Arch Defense Taskforce where you at?
jayofdoom
I'll note, lsblk can return a heck of a lot more data than it does by default (and nvme drives show up there). lsblk -H will list for your system, and you can specify columns. You can also adjust output.
I guess with this in mind, I'm curious how this is different?
trillic
Rewrote most of the functionality in C as an exercise
https://gist.github.com/grahameger/2507019334f07036f84080a87…