1

The purpose is to obtain information about the physical hard disk under the Linux platform. The required information include:

  • physical hard drive name (caption)
  • device path (such as /dev/sda)
  • read/write rate and read and write throughput of each physical disk
  • total disk capacity
  • remaining available capacity per physical disk

I eventually need to get this information in the program in C++. But I would also accept the command line acquisition method.

I have tried lshw, smartctl, hdparm, lsblk, fdisk, etc. But some of these commands are not available on different Linux distributions. As well, these methods can't get all the information I want.

I also tried to get information from /proc/diskstats, /sys/block, etc., but it didn't solve the problem. The confusion between logical disks and physical disks also makes processing difficult. It is important to emphasize that the information you need to obtain is for each physical disk.

Is there a more general way to use on most distributions?

  • Have you looked at the source code for these commands? – ctrl-alt-delor Mar 15 at 10:04
  • I have tracked several commands using the` strace `command. I am going to figure out the specifics of /proc files first, and then see how these commands work. – hxysayhi Mar 16 at 3:35

Your Answer

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

Browse other questions tagged or ask your own question.