简体   繁体   English

如何在Linux上获取磁盘信息?

[英]How to get disk information on Linux?

The purpose is to obtain information about the physical hard disk under the Linux platform. 目的是获取有关Linux平台下物理硬盘的信息。 The required information includes the 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 and remaining available capacity per physical disk. 所需信息包括物理硬盘驱动器名称 (标题), 设备路径 (例如/dev/sda ),每个物理磁盘的读/写速率 和读写吞吐量总磁盘容量以及每个物理磁盘的剩余可用容量 I eventually need to get this information in the program in C++. 我最终需要在C ++程序中获取此信息。 But I 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. 我尝试了lshwsmartctlhdparmlsblkfdisk .etc,但是其中一些命令在不同的Linux发行版中不可用。 And 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. 我还尝试从/proc/diskstats/sys/block等获取信息,但是并不能解决问题。 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. 需要强调的是,您需要获取的信息是针对每个物理磁盘的。

fdisk -l命令将向您显示详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM