linux如何查询硬盘信息

发布时间:2022-03-10 09:08:06 作者:iii
来源:亿速云 阅读:594

Linux如何查询硬盘信息

在Linux系统中,查询硬盘信息是一项常见的任务,无论是为了了解硬盘的容量、分区情况,还是为了检查硬盘的健康状态。本文将介绍几种常用的命令和工具,帮助你在Linux系统中查询硬盘信息。

1. 使用 lsblk 命令

lsblk 是一个简单而强大的命令,用于列出所有块设备的信息,包括硬盘、分区和挂载点。

lsblk

输出示例:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 464.3G  0 part /
sdb      8:16   0   1.8T  0 disk 
└─sdb1   8:17   0   1.8T  0 part /mnt/data

2. 使用 fdisk 命令

fdisk 是一个用于管理磁盘分区的工具,也可以用来查看硬盘的分区信息。

sudo fdisk -l

输出示例:

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 860 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 12345678-1234-1234-1234-123456789012

Device       Start       End   Sectors   Size Type
/dev/sda1     2048   1050623   1048576   512M EFI System
/dev/sda2  1050624 976773134 975722511 464.3G Linux filesystem

3. 使用 df 命令

df 命令用于显示文件系统的磁盘使用情况,包括挂载点和可用空间。

df -h

输出示例:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       464G  200G  240G  46% /
/dev/sdb1       1.8T  1.2T  600G  67% /mnt/data

4. 使用 smartctl 命令

smartctl 是一个用于查询硬盘健康状态的工具,支持S.M.A.R.T.技术。

首先,安装 smartmontools

sudo apt-get install smartmontools

然后,使用 smartctl 查询硬盘信息:

sudo smartctl -a /dev/sda

输出示例:

=== START OF INFORMATION SECTION ===
Model Family:     Samsung based SSDs
Device Model:     Samsung SSD 860 EVO 500GB
Serial Number:    S3Z8NB0K123456
Firmware Version: RVT02B6Q
User Capacity:    500,107,862,016 bytes [500 GB]
Sector Size:      512 bytes logical/physical
Rotation Rate:    Solid State Device
Form Factor:      2.5 inches
Device is:        In smartctl database [for details use: -P show]
ATA Version is:   ACS-2 T13/2015-D revision 3
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Mon Oct  2 12:34:56 2023 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

5. 使用 hdparm 命令

hdparm 是一个用于设置和查看硬盘参数的命令。

sudo hdparm -I /dev/sda

输出示例:

/dev/sda:

ATA device, with non-removable media
        Model Number:       Samsung SSD 860 EVO 500GB
        Serial Number:      S3Z8NB0K123456
        Firmware Revision:  RVT02B6Q
        Transport:          Serial, ATA8-AST, SATA 1.0a, SATA II Extensions, SATA Rev 2.5, SATA Rev 2.6, SATA Rev 3.0
Standards:
        Used: unknown (minor revision code 0x0028)
        Supported: 8 7 6 5
        Likely used: 8
Configuration:
        Logical         max     current
        cylinders       16383   16383
        heads           16      16
        sectors/track   63      63
        --
        CHS current addressable sectors:   16514064
        LBA    user addressable sectors:  268435455
        LBA48  user addressable sectors:  976773168
        Logical  Sector size:                   512 bytes
        Physical Sector size:                  512 bytes
        Logical Sector-0 offset:                  0 bytes
        device size with M = 1024*1024:      476940 MBytes
        device size with M = 1000*1000:      500107 MBytes (500 GB)
        cache/buffer size  = unknown
        Form Factor: 2.5 inch
        Nominal Media Rotation Rate: Solid State Device
Capabilities:
        LBA, IORDY(can be disabled)
        Queue depth: 32
        Standby timer values: spec'd by Standard, no device specific minimum
        R/W multiple sector transfer: Max = 16  Current = 16
        Advanced power management level: 254
        DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
             Cycle time: min=120ns recommended=120ns
        PIO: pio0 pio1 pio2 pio3 pio4
             Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
        Enabled Supported:
           *    SMART feature set
                Security Mode feature set
           *    Power Management feature set
           *    Write cache
           *    Look-ahead
           *    Host Protected Area feature set
           *    WRITE_BUFFER command
           *    READ_BUFFER command
           *    NOP cmd
           *    DOWNLOAD_MICROCODE
                SET_MAX security extension
           *    48-bit Address feature set
           *    Device Configuration Overlay feature set
           *    Mandatory FLUSH_CACHE
           *    FLUSH_CACHE_EXT
           *    SMART error logging
           *    SMART self-test
           *    General Purpose Logging feature set
           *    WRITE_{DMA|MULTIPLE}_FUA_EXT
           *    64-bit World wide name
           *    IDLE_IMMEDIATE with UNLOAD
           *    WRITE_UNCORRECTABLE_EXT command
           *    {READ,WRITE}_DMA_EXT_GPL commands
           *    Segmented DOWNLOAD_MICROCODE
           *    Gen1 signaling speed (1.5Gb/s)
           *    Gen2 signaling speed (3.0Gb/s)
           *    Gen3 signaling speed (6.0Gb/s)
           *    Native Command Queueing (NCQ)
           *    Phy event counters
           *    Host-initiated interface power management
           *    Device-initiated interface power management
           *    Software settings preservation
           *    SMART Command Transport (SCT) feature set
           *    SCT Write Same (AC2)
           *    SCT Error Recovery Control (AC3)
           *    SCT Features Control (AC4)
           *    SCT Data Tables (AC5)
Security:
        Master password revision code = 65534
                supported
        not     enabled
        not     locked
        not     frozen
        not     expired: security count
                supported: enhanced erase
        2min for SECURITY ERASE UNIT. 2min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5002538e12345678
        NAA             : 5
        IEEE OUI        : 002538
        Unique ID       : e12345678
Checksum: correct

结论

通过以上命令和工具,你可以轻松地在Linux系统中查询硬盘的详细信息。无论是查看硬盘的分区情况、使用情况,还是检查硬盘的健康状态,这些命令都能满足你的需求。根据具体情况选择合适的工具,可以帮助你更好地管理和维护你的硬盘。

推荐阅读:
  1. 如何查询PHP信息
  2. 使用linux的rpmquery命令查询信息

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux

上一篇:如何使用mybatis自定义日期类型转换器

下一篇:javascript中内置对象Math怎么使用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》