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: hdparm -I reads the identify data straight from a drive

Linux
~/tips/tip-disk-hdparm-i-identify

sudo hdparm -I /dev/sda

Asks the drive itself for detailed identification and feature data, not the kernel's boot-time copy.

hdparm has two lookalike options for drive info, and they don’t do the same thing. One reads what the kernel noted at boot. The other asks the drive.

sudo hdparm -I /dev/sda

The capital -I requests identification information directly from the drive and prints it in a detailed format. The lowercase -i shows the data the kernel drivers stored at boot or configuration time.

sudo hdparm -i /dev/sda

The man page warns that the lowercase data “may or may not be current”, depending on what happened since boot. So if you changed a feature and want to check it took effect, use -I. I’d also use it first when I want to know what a drive claims to support: model, firmware, features and whether it reports security or write cache settings.

The caveat: this is meant for ATA drives such as SATA disks, and you’ll want root because it opens the device. For an NVMe drive use nvme list and smartctl. Replace /dev/sda with the right device first, and check it with lsblk.

Two related options from the same man page are worth knowing. --Istdout dumps the drive’s identify data in hex to standard output, in a format suitable for later use with --Istdin. The man page says that --Istdin accepts such a block as input and must be the only parameter given.

sudo hdparm --Istdout /dev/sda > identify.hex
hdparm --Istdin < identify.hex

That makes it possible to save a drive’s identify block and read it later in the detailed -I format, for example to attach to a bug report. This was not run against a live drive; it follows the man page.

Further reading: hdparm man page

More Linux tips a2query -m rewrite renice -n 10 -p 4242 cat config.yml | xsel -ib xvfb-run -a your-program --some-flag dpkg --get-selections > packages.txt All Linux tips (261) All topics

Link