What's the reliable way to find out Hard Disk Information under Ubuntu, after having been booted for several days?

$ uptime 
 21:18:59 up 15 days, 10:46, 11 users,  load average: 1.01, 0.82, 0.65

I know normally the Hard Disk Information can be get from dmesg, on fresh reboot, but my system has only been up for 15 days, and I've already lost that info.

The FreeBSD Find Out All Installed Hard Disk Information says to check the /var/run/dmesg.boot file. The Linux Command To Find SATA says to check a log file called /var/log/messages. But under my Ubuntu I have none of them:

# Run as root,

% ls /var/run/dmesg.boot || echo no found
ls: cannot access /var/run/dmesg.boot: No such file or directory
no found

& ls /var/run/dmesg* || echo no found
ls: cannot access /var/run/dmesg*: No such file or directory
no found

% ls /var/log/me* || echo no found
ls: cannot access /var/log/me*: No such file or directory
no found

% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 15.04
Release:        15.04
Codename:       vivid

# and I've also checked:
% cat /var/log/dmesg 
(Nothing has been logged yet.)

% grep -i ata /var/log/boot.log 
         Starting Increase datagram queue length...
[  OK  ] Started Increase datagram queue length.
         Starting Tell Plymouth To Write Out Runtime Data...
[  OK  ] Started Tell Plymouth To Write Out Runtime Data.

My syslog says there is something wrong with my ata2, however, because Linux/Ubuntu swap disk orders all the times, I want to know exactly which of my 3 drives is ata2. Thanks.


It depends on the kind of information you are searching for. The proper way is to use

udevadm info -a -n /dev/sda

This returns all info which udev has. If you want the partition table,

parted /dev/sda

and the p (for print) will show you the partition table. If you want to take a look at your MBR (if you have one), then

dd if=/dev/sda of=mbr.bin bs=512 count=1
hexdump -C mbr.bin

If instead you want messages, including error messages, produced in the current session, then

dmesg | grep sda

or some such thing. dmesg displays the messages stored in /var/log/dmesg. Unless of course you are on systemd, in which case the above command still works, but you can display the kernel messages as follows:

sudo journalctl | grep sda

(sudo is important, if you omit it you will only display the user journal, not the kernel's).

Or you can query general information about the disk by means of

lshw -C disk

Or you can use dmidecode (not available on more recent versions of Linux) which allows you access to your hardware as seen in the BIOS (or, more exactly, in the SMBIOS, System Management BIOS). Notice that this does not scan your system, but simply reports what the BIOS says your pc is like.

If this is not enough, you may have to resort to a diagnostic tool, like smartctl.


As root:

hdparm -i /dev/XXX will tell you the geometry of the disk.

smartctl -i /dev/XXX will tell you similar information as well as disk status.

  • Thank you @davidgo, you anser precisely solved my problem, but please allow me to mark MariusMatutiae's as the answer, as he has put much efforts into it. Thanks – xpt Dec 14 '15 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.