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

相关推荐

  • Linux下make安装的软件怎样安全卸载?

    方法1:使用 make uninstall(推荐优先尝试)如果软件的 Makefile 提供了卸载目标:cd /path/to/source-code # 进入源码目录sudo make uninstall # 执行卸载原理:开发者若在 Makefile 中定义了 uninstall 规则,该命令会反向删除安装……

    2025年6月25日
    13800
  • Linux中如何用evince命令查看PDF文档?

    Evince是Linux操作系统下一款轻量级且功能全面的文档查看器,作为GNOME桌面环境的默认组件,它主要用于打开和浏览PDF、PostScript、DjVu、XPS、TIFF等多种格式的文档,其界面简洁、操作直观,同时支持丰富的命令行参数,方便用户通过终端进行自动化或个性化操作,本文将详细介绍Evince的……

    2025年8月24日
    11800
  • Linux系统如何打开系统盘并访问其内容?

    在Linux系统中,“系统盘”通常指安装操作系统的分区,如根分区(/)、引导分区(/boot)或/home分区等,与Windows不同,Linux的分区管理更强调命令行操作和权限控制,但图形界面也能满足基本需求,以下是详细的开机和访问方法,涵盖图形界面、命令行操作及特殊情况处理,Linux系统盘的识别与基本概念……

    2025年10月2日
    7800
  • Linux系统如何删除PV卷?操作步骤、命令及注意事项?

    在Linux系统中,物理卷(Physical Volume,PV)是LVM(逻辑卷管理)中最基础的存储单元,它可以是硬盘分区、RAID设备或LUN(逻辑单元号),当需要调整存储结构、释放磁盘空间或替换硬件时,可能需要删除PV卷,删除PV操作需谨慎处理,尤其是当PV属于某个卷组(VG)时,操作不当可能导致数据丢失……

    2025年10月8日
    10000
  • 如何在Linux安装并配置FTP服务器?

    在Linux系统中搭建FTP服务器是许多企业和个人用户的需求,FTP(文件传输协议)用于在客户端和服务器之间进行文件传输,尤其适合需要频繁上传下载文件的场景,本文将以常用的vsftpd(Very Secure FTP Daemon)为例,详细介绍在Linux系统上安装、配置FTP服务器的完整步骤,包括安装软件包……

    2025年9月16日
    11100

发表回复

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

联系我们

400-880-8834

在线咨询: QQ交谈

邮件:HI@E.KD.CN

关注微信