brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: lsscsi -s lists your disks with their sizes

Disk
~/tips/tip-hardware-lsscsi-s-disks

lsscsi -s

Lists SCSI-layer devices such as disks with capacity, in one line each.

I keep forgetting which of my disks is which when the machine has a pile of them. lsblk is my first stop, and lsscsi is a nice second one because it adds the vendor and model strings in a compact list.

lsscsi -s

Each line starts with the host:channel:target:lun tuple in brackets, then the device type, the vendor and model strings and the device name. -s adds the capacity in a human readable form.

lsscsi -s -t
lsscsi -g
lsscsi -H
  • -t adds transport information.
  • -g adds the SCSI generic device file.
  • -H lists the SCSI hosts and NVMe controllers instead of the devices.

The caveat: lsscsi is not always installed, so look for the lsscsi package. It lists what the kernel exposes through its SCSI layer, and SATA and USB storage normally show up there too. For the exact drive details, follow up with smartctl -i or hdparm -I on the device you picked.

The device tuple at the start of each line is also what you see in kernel messages, so it is a way to connect a dmesg error about “sd 2:0:0:0” to an actual disk.

Further reading: lsscsi man page

More Disk tips sudo e2freefrag /dev/sdb1 sudo smartctl -a --json /dev/sda | jq '.smart_status.passed' udisksctl power-off -b /dev/sdX du -sh — .[!.]* * 2>/dev/null | sort -h ls -l /dev/disk/by-id/ All Disk tips (44) All topics

Link