linux-查看硬盘信息命令

woooooon 2024-08-17 17:07:04 阅读 86

linux-查看硬盘信息命令

一、 df命令二、du 命令三、lsblk命令四、fdisk命令五、smartctl命令

Linux查看硬盘信息的几种命令包括df、du、lsblk、fdisk、smartctl。

一、 df命令

df -h 是最常见的磁盘查看命令。它可以显示文件系统的总大小、已用空间、可用空间和挂载点等信息。

<code>[root@FZCTP-DB ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 110G 46G 65G 42% /

/dev/mapper/centos-data 1.9T 1.5T 389G 80% /data

/dev/vda2 1014M 196M 819M 20% /boot

/dev/vdb1 1.0T 14G 1011G 2% /backup

tmpfs 41G 12G 30G 29% /dev/shm

tmpfs 32G 2.2G 30G 7% /run

tmpfs 32G 0 32G 0% /sys/fs/cgroup

tmpfs 6.3G 40K 6.3G 1% /run/user/0

tmpfs 6.3G 0 6.3G 0% /run/user/1001

/dev/sr0 4.3G 4.3G 0 100% /mnt/cdrom

devtmpfs 32G 0 32G 0% /dev

“Size”表示文件系统总大小,“Used”表示已使用大小,“Avail”表示可用空间linux启动盘制作工具,“Use%”表示已使用百分比

二、du 命令

du命令是用于查看目录或文件占用磁盘空间的命令。

常用命令和选项,统计当前目录下的文件和目录占用空间

[root@FZCTP-DB ~]# du -sh *

4.0K anaconda-ks.cfg

4.0K Desktop

4.0K Documents

20K Downloads

64K install.log

12K install.log.syslog

11G logs

4.0K Music

4.0K Pictures

4.0K Public

436K soft

-s, --summarize 仅显示总计,只列出最后加总的值。

-h, --human-readable 以K,M,G为单位,提高信息的可读性。

常看指定目录下所有文件的大小(会遍历所有文件)

[root@FZCTP-DB tomcat]# du -h apache-tomcat-9.0.36/

6.5M apache-tomcat-9.0.36/webapps/java/applets

16K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/uploader/resolver

20K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/uploader

16K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/view/output

20K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/view/resolver

48K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/view

12K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/web/resolver

16K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado/web

88K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/dorado

36K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/bdf2/export/excel

12K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/bdf2/export/csv

8.0K apache-tomcat-9.0.36/webapps/java/WEB-INF/classes/com/bstek/bdf2/export/pdf/model

将文件从大到小排序

du -sh * |sort -rh

三、lsblk命令

lsblk该命令可以列出系统中所有块设备(如硬盘、SSD 等)的信息,包括设备名称、容量、挂载点等。通过这个命令可以方便地了解系统硬件配置和磁盘分区情况。

[root@FZCTP-DB ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda 8:0 0 558.9G 0 disk

|-sda1 8:1 0 500M 0 part /boot/efi

|-sda2 8:2 0 500M 0 part /boot

`-sda3 8:3 0 557.9G 0 part

|-vg_fzctpdb-LogVol00_swap (dm-0) 253:0 0 64G 0 lvm [SWAP]

|-vg_fzctpdb-LogVol04_root (dm-1) 253:1 0 453.9G 0 lvm /

|-vg_fzctpdb-LogVol03_var (dm-2) 253:2 0 20G 0 lvm /var

|-vg_fzctpdb-LogVol02_usr (dm-3) 253:3 0 10G 0 lvm /usr

`-vg_fzctpdb-LogVol01_tmp (dm-4) 253:4 0 10G 0 lvm /tmp

四、fdisk命令

fdisk 命令可以显示系统中所有硬盘的分区情况,包括分区类型、容量、起始位置等信息。通过这个命令可以查看系统磁盘的物理结构和分布情况。

[root@FZ-DB ~]# fdisk -l

Disk /dev/sda: 600.1 GB, 600093712384 bytes

255 heads, 63 sectors/track, 72957 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 262144 bytes / 262144 bytes

Disk identifier: 0x00000000

Device Boot Start End Blocks Id System

/dev/sda1 1 72958 586029015+ ee GPT

Partition 1 does not start on physical sector boundary.

Disk /dev/mapper/vg_fzctpdb-LogVol00_swap: 68.7 GB, 68719476736 bytes

255 heads, 63 sectors/track, 8354 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 262144 bytes / 262144 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_fzctpdb-LogVol04_root: 487.4 GB, 487369736192 bytes

255 heads, 63 sectors/track, 59252 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 262144 bytes / 262144 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_fzctpdb-LogVol03_var: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 262144 bytes / 262144 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_fzctpdb-LogVol02_usr: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 262144 bytes / 262144 bytes

Disk identifier: 0x00000000

Disk /dev/mapper/vg_fzctpdb-LogVol01_tmp: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 262144 bytes / 262144 bytes

Disk identifier: 0x00000000

五、smartctl命令

smartctl命令是用于检测硬盘健康状态并显示相关信息的命令。它可以显示硬盘的温度、寿命预测、错误记录等信息。

[root@FZ-DB ~]# smartctl -a /dev/sda

smartctl 5.43 2016-09-28 r4347 [x86_64-linux-2.6.32-696.el6.x86_64] (local build)

Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net

Vendor: HP

Product: LOGICAL VOLUME

Revision: 5.52

User Capacity: 600,093,712,384 bytes [600 GB]

Logical block size: 512 bytes

Logical Unit id: 0x600508b1001c13ef256161d9825110ea

Serial number: PDNLH0BRH981LP

Device type: disk

Local Time is: Wed Jun 19 10:24:12 2024 CST

Device supports SMART and is Enabled

Temperature Warning Disabled or Not Supported

SMART Health Status: OK

Error Counter logging not supported

Device does not support Self Test logging

https://www.linuxcool.com/lypkjzkmlff

https://zhuanlan.zhihu.com/p/688628108



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。