在CentOS系统中,你可以使用多种命令来检查分区的状态。以下是一些常用的命令:
df
命令df
命令用于显示文件系统的磁盘空间使用情况。
df -h
-h
选项以人类可读的格式显示大小(例如 KB, MB, GB)。示例输出:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 20G 5G 14G 26% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sdb1 100G 10G 85G 11% /mnt/data
fdisk
命令fdisk
命令用于管理磁盘分区。
sudo fdisk -l
这个命令会列出所有磁盘及其分区信息。
lsblk
命令lsblk
命令用于列出所有块设备的信息。
lsblk
示例输出:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 20G 0 part /
sdb 8:16 0 100G 0 disk
└─sdb1 8:17 0 100G 0 part /mnt/data
tmpfs 12:0 0 3.9G 0 tmpfs
└─tmpfs 12:1 0 3.9G 0 tmpfs /dev/shm
parted
命令parted
命令用于管理磁盘分区。
sudo parted -l
这个命令会列出所有磁盘及其分区信息。
smartctl
命令smartctl
命令用于检查硬盘的健康状态。
首先,你需要安装 smartmontools
包:
sudo yum install smartmontools
然后运行以下命令:
sudo smartctl -a /dev/sda
示例输出:
smartctl 6.5 2016-01-24 r4294 -:1.40.1 (1) (http://smartmontools.sourceforge.net)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Device Model: Seagate Barracuda 7200.14 (SCSI)
Serial Number: WDCWDN00108094
LU WWN Device Id: 5 000039 100000000
Firmware Version: CC45
User Capacity: 2,000,398,934,016 bytes [2.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 7200 rpm
Form Factor: 3.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ATA8-ACS T13/1699-D revision 6
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 1.5 Gb/s)
Local Time is: Thu Apr 6 12:34:56 2023 UTC
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x80) Offline data collection activity was never started.
Self-test execution status: ( 0) The previous self-test routine completed without error or no self-test has ever been run.
Total time to complete Offline
data collection: ( 1234) seconds.
Offline data collection
capabilities: (0x5b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
write command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART access control is: (0x7f) Open
Write cache status: Enabled
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed without error 00% 1234 -
# 2 Extended offline Completed without error 00% 1234 -
# 3 Short offline Completed without error 00% 1234 -
# 4 Extended offline Completed without error 00% 1234 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA Current_Test_Status
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
这些命令可以帮助你全面了解CentOS系统的分区状态和硬盘健康状况。