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)
酷番叔酷番叔
上一篇 2025年8月15日 07:49
下一篇 2025年8月15日 07:54

相关推荐

  • Linux7.3系统如何重置root密码?

    在Linux 7.3系统中(通常指基于RHEL 7.3的发行版,如CentOS 7.3),若忘记root密码或用户密码,可通过引导进入紧急模式或单用户模式重置密码,操作需物理访问服务器或控制台权限,具体步骤如下:重置密码操作步骤进入GRUB引导菜单重启服务器,在开机自检阶段(显示厂商LOGO时)迅速按下Shif……

    2025年9月18日
    7200
  • Linux的ISO镜像文件如何安装系统到电脑硬盘?

    Linux的ISO文件是操作系统的镜像,通过它可以安装完整的Linux系统,安装过程需要准备安装介质、设置启动项、进行分区配置等步骤,以下是详细操作流程:准备工作下载ISO镜像:从Linux发行版官网(如Ubuntu、CentOS、Debian等)下载对应版本的ISO文件,确保与硬件架构匹配(如x86_64或A……

    2025年9月24日
    7700
  • 为什么火狐浏览器打不开怎么办

    在Linux系统中,开启进程是日常操作的核心任务之一,无论是运行简单脚本还是部署关键服务,理解多种进程启动方式至关重要,以下内容基于Linux内核文档、man命令手册及开源社区最佳实践,确保专业性和可靠性,进程基础概念进程是正在执行的程序的实例,Linux中每个进程拥有独立的内存空间和资源,通过PID(进程ID……

    2025年7月21日
    9900
  • linux如何把一个文件

    Linux 中,可使用 mv 命令将一个文件移动到指定目录,如

    2025年8月18日
    7900
  • linux下如何安装python

    在Linux系统中安装Python是开发环境搭建的基础步骤,常见方法包括包管理器安装、源码编译安装及虚拟环境配置,本文以主流发行版(如Ubuntu/Debian、CentOS/RHEL、Fedora)为例,详细说明不同场景下的安装流程及注意事项,通过包管理器安装(适合新手快速部署)包管理器安装是最简单的方式,但……

    2025年8月23日
    8800

发表回复

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

联系我们

400-880-8834

在线咨询: QQ交谈

邮件:HI@E.KD.CN

关注微信