溫馨提示×

Linux分區后如何檢查

小樊
34
2025-07-23 07:07:14
欄目: 智能運維

在Linux系統中,分區后可以通過以下幾種方法來檢查分區的狀態和完整性:

1. 使用 lsblk 命令

lsblk 命令可以列出所有可用的塊設備及其掛載點。

lsblk

輸出示例:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   100G  0 disk 
├─sda1   8:1    0   50G  0 part /
├─sda2   8:2    0   50G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom  

2. 使用 fdiskparted 命令

fdiskparted 命令可以用來查看和管理磁盤分區。

使用 fdisk

sudo fdisk -l

輸出示例:

Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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: 0x000a9e6b

Device     Boot Start       End   Sectors Size Id Type
/dev/sda1  *       2048 104857599 104855552  50G 83 Linux
/dev/sda2      104857600 209715199 104857599  50G 82 Linux swap / Solaris

使用 parted

sudo parted -l

輸出示例:

Model: ATA ST1000LM024H (scsi)
Disk /dev/sda: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  51.2GB  51.2GB  ext4
 2      51.2GB  100GB   48.8GB  linux-swap(v1)

3. 使用 df 命令

df 命令可以顯示文件系統的磁盤空間使用情況。

df -h

輸出示例:

Filesystem Size Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           798M  9.6M  788M   2% /run
/dev/sda1       50G   10G   38G  21% /
tmpfs           3.9G   12M  3.9G   1% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda2       50G     0   50G   0% [SWAP]

4. 使用 mount 命令

mount 命令可以顯示當前掛載的文件系統。

mount | column -t

輸出示例:

/dev/sda1 on / type ext4 (rw,relatime,data=ordered)
sysfs on /sys type sysfs (rw,nosuid,noexec,relatime)
proc on /proc type proc (rw,nosuid,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=3932128k,nr_inodes=983032,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=798M,mode=755)
/dev/sda2 on none type swap (rw,nosuid,noexec,relatime)

5. 使用 smartctl 命令

smartctl 是一個用于監控硬盤健康狀況的工具,可以檢查硬盤的SMART信息。

首先安裝 smartmontools

sudo apt-get install smartmontools  # Debian/Ubuntu
sudo yum install smartmontools      # CentOS/RHEL

然后檢查硬盤健康狀況:

sudo smartctl -a /dev/sda

輸出示例:

smartctl 6.2 2013-07-29 r3784 [x86_64-linux-3.2.0-4-amd64] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     ATA ST1000LM024H
Serial Number:    WDCWCAVX01960
Firmware Version: CC45
User Capacity:    100,020,000,128 bytes [100 GB]
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:   ACS-2 (minor revision not indicated)
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 CEST
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.
Automatic Offline Data Collection Frequency: (0x80) Offline data collection activity
                    is not scheduled.
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:        (   120) seconds.
Offline data collection
capabilities:                                                  (0x7b) 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 capabilities:            (0x0003) Saves SMART data before entering
                    power-saving mode.
                    Supports SMART auto save timer.
Error logging capability:        (0x01) Error logging supported.
                    General Purpose Logging supported.
Short self-test routine 
recommended polling time:    (   2) minutes.
Extended self-test routine
recommended polling time:    (  19) minutes.
Conveyance self-test routine
recommended polling time:    (   5) minutes.
SCT capabilities:              (0x703f) SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
 1 Raw_Read_Error_Rate     0x002f   200   200   051    Pre-fail  Always       -       0
 3 Spin_Up_Time            0x0027   100   100   020    Pre-fail  Always       -       0
 4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       5
 5 Reallocated_Sector_Ct   0x0033   200   200   140    Pre-fail  Always       -       0
 7 Seek_Error_Rate         0x002e   200   200   000    Old_age   Always       -       0
 9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       1234
10 Spin_Retry_Count        0x0032   200   200   100    Old_age   Always       -       0
11 Calibration_Retry_Count 0x0032   200   200   000    Old_age   Always       -       0
12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       5
197 Current_Pending_Sector  0x0012   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0010   100   100   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x003e   200   200   000    Old_age   Always       -       0

SMART Error Log Version: 1
No Error Log present

通過以上方法,你可以全面檢查Linux系統的分區狀態和完整性。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女