linux下如何查看硬盘

Linux 下,可使用“df -h”查看硬盘使用情况,“lsblk

Linux系统中,查看硬盘信息是一项常见的操作,无论是了解硬盘的容量、使用情况,还是诊断硬件问题,都可能需要查看硬盘的相关信息,以下是几种在Linux下查看硬盘信息的常用方法:

使用lsblk命令

lsblk(list block devices)命令用于列出所有块设备的信息,包括硬盘、分区等,它以树状结构显示设备之间的关系,非常直观。

示例输出:

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 232.9G  0 disk 
├─sda1        8:1    0 232.9G  0 part /home
└─sda2        8:2    0     1K  0 part 
sdb           8:16   0 149.1G  0 disk 
└─sdb1        8:17   0 149.1G  0 part /mnt/data

解释:

  • NAME:设备名称。
  • MAJ:MIN:主设备号和次设备号。
  • RM:是否可移除(1表示可移除,0表示不可移除)。
  • SIZE:设备大小。
  • RO:是否只读(1表示只读,0表示可读写)。
  • TYPE:设备类型(disk表示硬盘,part表示分区)。
  • MOUNTPOINT:挂载点。

使用fdisk命令

fdisk命令主要用于磁盘分区,但也可以用来查看硬盘的分区表信息。

示例输出:

$ sudo fdisk -l
Disk /dev/sda: 232.9 GiB, 250000000000 bytes, 488397168 sectors
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: dos
Disk identifier: 0x12345678
Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1  *        2048 488397167 488395120 232.9G 83 Linux
/dev/sda2       488397168 488397311      144   72K 82 Linux swap / Solaris

解释:

  • Disk /dev/sda:设备名称。
  • 9 GiB:硬盘大小。
  • Sector size:扇区大小。
  • Disklabel type:磁盘标签类型。
  • Device:分区设备名称。
  • Boot:是否为启动分区。
  • StartEnd:分区的起始和结束扇区。
  • Sectors:分区大小(以扇区为单位)。
  • Size:分区大小。
  • Id:分区类型ID。
  • Type:分区类型。

使用df命令

df(disk free)命令用于查看文件系统的磁盘空间使用情况,包括已用空间、可用空间等。

示例输出:

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       232G   50G  177G  23% /home
/dev/sda2         72K     0   72K   0% [SWAP]
/dev/sdb1       149G   30G  109G  22% /mnt/data

解释:

  • Filesystem:文件系统所在的设备。
  • Size:文件系统的大小。
  • Used:已用空间。
  • Avail:可用空间。
  • Use%:已用空间百分比。
  • Mounted on:挂载点。

使用du命令

du(disk usage)命令用于查看目录或文件的磁盘使用情况,通常与-sh选项一起使用,以人类可读的格式显示总大小。

示例输出:

$ du -sh /home
23G    /home

解释:

  • du -sh /home:显示/home目录的总大小。

使用blkid命令

blkid命令用于查看块设备的属性,如UUID、文件系统类型等。

示例输出:

$ sudo blkid
/dev/sda1: UUID="1234-5678" TYPE="ext4"
/dev/sda2: UUID="9abc-def0" TYPE="swap"
/dev/sdb1: UUID="5678-1234" TYPE="ext4"

解释:

  • UUID:通用唯一标识符,用于标识文件系统。
  • TYPE:文件系统类型。

使用lsblkdf结合查看

有时,结合使用lsblkdf命令可以更全面地了解硬盘的使用情况。

示例输出:

$ lsblk -f
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                                
├─sda1 ext4          1234-5678                           /home
└─sda2 swap          9abc-def0                            [SWAP]
sdb                                                                
└─sdb1 ext4          5678-1234                           /mnt/data

解释:

  • FSTYPE:文件系统类型。
  • LABEL:文件系统标签。
  • UUID:文件系统UUID。
  • MOUNTPOINT:挂载点。

使用hdparm命令查看硬盘健康状态

hdparm命令用于查看和设置硬盘的参数,包括硬盘的健康状态、缓存大小、传输速率等。

示例输出:

$ sudo hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Standards:
    Uses: ATA8-ACS revision 4
    Supports ATA feature set ACS-2
    Supports ATA commands
    Supports IDLEWIRE command
    Supports power management
...

解释:

  • hdparm -I /dev/sda:显示/dev/sda硬盘的详细信息,包括型号、容量、缓存大小、传输模式等。

使用smartctl命令查看硬盘健康状态

smartctl命令用于监控硬盘的健康状态,支持SMART(Self-Monitoring, Analysis and Reporting Technology)技术的硬盘。

示例输出:

$ sudo smartctl -a /dev/sda
smartctl 7.1 2023-01-01 r5157 [x86_64-linux-5.4.0-123-generic] (local build)
Copyright (C) 2002-2023 Smartmontools team
Starting self-test on /dev/sda: done
Reading SMART data from /dev/sda: done
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status:  (0x00) Offline data collection activity was never started.
Auto Offline Data Collection: Enabled.
Self-test execution status: (   0) The previous self-test routine completed without error or no self-test has ever been started.
Total time to complete Offline data collection: (14400) seconds.
Offline data collection capabilities: (0x7b) SMART execute Offline immediate. Auto Offline data collection on/off support. Suspend Offline collection upon new command. Offline surface scan supported. Self-test supported. Conveyance Self-test supported. Selective Self-test supported. Automatic Offline data collection on/off support. Abort offline collection upon new command. Offline surface scan supported. Self-test supported. Conveyance Self-test supported. Selective Self-test supported. Automatic Offline data collection on/off support. Abort offline collection upon new command. Offline surface scan supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported. No Automatic Offline data collection on/off support. Abort offline collection upon new command. No Offline surface scan supported. No Self-test supported. No Conveyance Self-test supported. No Selective Self-test supported.

以上内容就是解答有关linux下如何查看硬盘的详细内容了,我相信这篇文章可以为您解决一些疑惑,有任何问题欢迎留言反馈,谢谢阅读。

原创文章,发布者:酷番叔,转转请注明出处:https://cloud.kd.cn/ask/10995.html

(0)
酷番叔酷番叔
上一篇 1小时前
下一篇 1小时前

相关推荐

  • Linux如何用命令行刻录光盘?

    准备工作硬件检查确认光驱支持刻录功能(设备名通常为 /dev/sr0 或 /dev/cdrom),插入空白光盘(CD-R、DVD±R、BD-R 等),安装刻录工具根据发行版选择安装命令:# Debian/Ubuntusudo apt install wodim brasero k3b growisofs# Fe……

    2025年7月28日
    1000
  • Linux各发行版如何安全高效安装软件?

    通过包管理器安装(推荐)原理:Linux发行版通过官方软件仓库管理软件,由维护者审核确保安全性和兼容性,优势:自动处理依赖关系、一键更新/卸载、安全性高,常用命令(根据发行版选择):发行版安装命令更新软件源卸载命令Ubuntu/Debiansudo apt install 软件名sudo apt updates……

    2025年7月8日
    1900
  • 为什么你还没用XX?3个理由说服你

    include是C/C++中的预处理指令,用于在编译前将指定头文件的内容插入当前文件,它允许代码复用、声明共享,是模块化编程的基础。

    2025年6月13日
    3000
  • U盘连接电脑后为何无法访问文件?

    物理连接设备后建立网络通信链路,进行网络配置与身份验证,成功接入服务端后即可定位、传输或操作目标文件资源。

    2025年6月21日
    2900
  • 如何将整个磁盘备份为镜像文件到移动硬盘?

    为什么需要系统备份?数据安全:防止硬件故障、误操作或病毒导致的数据丢失,系统迁移:快速将系统复制到新硬盘或新设备,灾难恢复:系统崩溃后10分钟内还原到正常状态,测试环境:备份后可安全测试新软件或配置,随时回滚,推荐工具及选择建议Clonezilla(首选工具)优点:支持全盘/分区备份、增量备份、跨平台(EXT4……

    2025年8月7日
    700

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们

400-880-8834

在线咨询: QQ交谈

邮件:HI@E.KD.CN

关注微信