如何在启动期间强制修复文件系统

如何在启动期间强制修复文件系统

我有两个磁盘,分别在//home/,并且都显示错误e2fsck -fn /dev/<disk>(-f = 即使“干净”也检查,-n = 只读模式)

我该如何修复这些文件系统错误?

我设法启用启动时扫描(不确定是否同时扫描两个磁盘),但之后两个磁盘仍然出现错误。


细节

我按照指南进行操作https://linuxconfig.org/how-to-force-fsck-to-check-filesystem-after-system-reboot-on-linux并且使用 touch 文件的方法甚至对根磁盘也不起作用。Ubuntu 抱怨:

2 月 11 日 17:11:02 标记 systemd-fsck[690]: 请在内核命令行上传递“fsck.mode=force”,而不是在根文件系统上创建 /forcefsck。

我在两个磁盘上尝试了第二个选项,编辑/etc/fstab以将结果代码设置为2并对两个磁盘执行tune2fs -c 1 /dev/disk。从那时起,在每次启动期间我都会看到:

按 Ctrl+C 取消正在进行的所有文件系统检查
正在对 1 个磁盘进行检查(已完成 26.0%)

它显示 1 个磁盘(我预计是 2 个)。它从 26% 开始,然后上升到(几乎)100%。(它看起来像那样是因为显示器正在切换分辨率)

登录后,当我e2fsck在两个磁盘上执行时,我仍然发现多个错误,例如孤立的 inode、错误的空闲节点数、零 dtime inode、块位图差异等。

e2fsck我怎样才能修复启动时发现的错误?


错误:

mark@mark:~$ sudo e2fsck -nf /dev/sda5; sudo e2fsck -nf /dev/sdb1
e2fsck 1.44.1 (24-Mar-2018)
Warning!  /dev/sda5 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (51260638, counted=51258463).
Fix? no

Free inodes count wrong (13280655, counted=13280622).
Fix? no

/dev/sda5: 154225/13434880 files (0.1% non-contiguous), 2464034/53724672 blocks
e2fsck 1.44.1 (24-Mar-2018)
Warning!  /dev/sdb1 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked list found.  Fix? no

Inode 21235676 was part of the orphaned inode list.  IGNORED.
Inode 21236927 was part of the orphaned inode list.  IGNORED.
Inode 21237621 was part of the orphaned inode list.  IGNORED.
Inode 21237990 was part of the orphaned inode list.  IGNORED.
Inode 21238402 was part of the orphaned inode list.  IGNORED.
Inode 21238464 was part of the orphaned inode list.  IGNORED.
Deleted inode 21238506 has zero dtime.  Fix? no

Inode 21238523 was part of the orphaned inode list.  IGNORED.
Inode 21238553 was part of the orphaned inode list.  IGNORED.
Inode 35651957 was part of the orphaned inode list.  IGNORED.
Pass 2: Checking directory structure
Entry 'Ubuntu notes.txt' in /mark/Documents (21233680) has deleted/unused inode 21238530.  Clear? no

Entry 'desktop-metadata' in /mark/.config/nautilus (21233804) has deleted/unused inode 21238525.  Clear? no

Entry 'xulstore.json' in /mark/.thunderbird/rhccmynw.default (21495857) has deleted/unused inode 21498027.  Clear? no

Entry 'lock' in /mark/.thunderbird/rhccmynw.default (21495857) has deleted/unused inode 21497953.  Clear? no

Entry 'global-messages-db.sqlite-journal' in /mark/.thunderbird/rhccmynw.default (21495857) references inode 21498857 found in group 2624's unused inodes area.
Fix? no

Entry 'global-messages-db.sqlite-journal' in /mark/.thunderbird/rhccmynw.default (21495857) has deleted/unused inode 21498857.  Clear? no

Entry 'cba86d7c-56f1-4b53-9002-e6008d7ec077' in /mark/.thunderbird/rhccmynw.default/saved-telemetry-pings (21629137) has deleted/unused inode 21627358.  Clear? no

Entry 'recovery.baklz4' in /mark/.mozilla/firefox/1oxfnaca.default-1536326026399/sessionstore-backups (23592969) has deleted/unused inode 23594226.  Clear? no

Entry 'storage.js' in /mark/.mozilla/firefox/1oxfnaca.default-1536326026399/browser-extension-data/[email protected] (26869816) has deleted/unused inode 26869799.  Clear? no

Entry 'home-132a535f.log' in /mark/.local/share/gvfs-metadata (21233829) has deleted/unused inode 21238552.  Clear? no

Entry 'DEB72738C9A4BD2631567485A211516096512633' in /mark/.cache/thunderbird/rhccmynw.default/cache2/entries (21233899) has deleted/unused inode 21238528.  Clear? no

Entry 'E86D0879A15003F74582DAA01F04268E5E3A6193' in /mark/.cache/thunderbird/rhccmynw.default/cache2/entries (21233899) has deleted/unused inode 21238550.  Clear? no

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Unattached inode 21238336
Connect to /lost+found? no

Unattached inode 21238501
Connect to /lost+found? no

Unattached zero-length inode 21498131.  Clear? no

Unattached inode 21498131
Connect to /lost+found? no

Unattached zero-length inode 23593885.  Clear? no

Unattached inode 23593885
Connect to /lost+found? no

Unattached zero-length inode 26869802.  Clear? no

Unattached inode 26869802
Connect to /lost+found? no

Pass 5: Checking group summary information
Block bitmap differences:  -(84968536--84968537) -(84968580--84968581) -84968797 +(84968918--84968919) -(84969152--84969154) +(84970738--84970739) -(84971372--84971374) -(84971940--84971961) -(84971993--84972003) +85247486 -(85288043--85288050) +(85288078--85288079) -(85418135--85418145) +(85418146--85418148) +85578637 -(85581356--85581366) -(85581436--85581437) -(85581454--85581470) -(85581486--85581490) -(85581862--85581873) -(85581875--85581885) +85582421 -85582422 -(85582435--85582436) -85582440 -(85582460--85582470) -(85582476--85582477) -(85587974--85587984) +(85588047--85588054) -85588058 -(85588061--85588088) -85588094 -(85689681--85689810) -(86016016--86016017) +(86016046--86016047) +86016126 +(86016205--86016207) -(86016244--86016247) +(86384640--86384647) +(86453944--86453945) +(86454004--86454008) -(86540452--86540454) -88113216 -(88836576--88836603) -(90732824--90732825) -(94589879--94589887) -(94590320--94590334) -(110201600--110201638) -(110209536--110209696) +(129848128--129848166) -(136747992--136749179) -(138456000--138456038) +(142697944--142697951) +(142697953--142697977) +(142701330--142701332)
Fix? no

Free blocks count wrong for group #2593 (20540, counted=20533).
Fix? no

Free blocks count wrong for group #2601 (27008, counted=27009).
Fix? no

Free blocks count wrong for group #2602 (30229, counted=30231).
Fix? no

Free blocks count wrong for group #2606 (17690, counted=17693).
Fix? no

Free blocks count wrong for group #2611 (18206, counted=18122).
Fix? no

Free blocks count wrong for group #2615 (18615, counted=18485).
Fix? no

Free blocks count wrong for group #2636 (26230, counted=26238).
Fix? no

Free blocks count wrong for group #2638 (19435, counted=19446).
Fix? no

Free blocks count wrong for group #2641 (29547, counted=29544).
Fix? no

Free blocks count wrong for group #2712 (18146, counted=18130).
Fix? no

Free blocks count wrong for group #2768 (15344, counted=15342).
Fix? no

Free blocks count wrong for group #2884 (974, counted=971).
Fix? no

Free blocks count wrong for group #2886 (6832, counted=6822).
Fix? no

Free blocks count wrong for group #3360 (22484, counted=21894).
Fix? no

Free blocks count wrong for group #3363 (3835, counted=3635).
Fix? no

Free blocks count wrong for group #3962 (5153, counted=5192).
Fix? no

Free blocks count wrong for group #4173 (26643, counted=25455).
Fix? no

Free blocks count wrong for group #4354 (25277, counted=25313).
Fix? no

Free blocks count wrong (189550061, counted=189547835).
Fix? no

Inode bitmap differences:  -21235676 -21236927 -21237621 -21237990 -21238402 -21238464 -21238506 -21238523 -21238525 -21238528 -21238530 -21238550 -(21238552--21238553) -21497953 -21498027 +21498131 -21498857 -21627358 +23593885 -23594226 -26869799 +26869802 -27918519 -27918526 -35651957
Fix? no

Free inodes count wrong for group #2592 (2527, counted=2522).
Fix? no

Free inodes count wrong for group #2624 (5146, counted=5144).
Fix? no

Free inodes count wrong for group #2640 (6403, counted=6402).
Fix? no

Free inodes count wrong for group #2880 (140, counted=139).
Fix? no

Free inodes count wrong for group #3408 (5367, counted=5365).
Fix? no

Free inodes count wrong (60153933, counted=60153866).
Fix? no


/dev/sdb1: ********** WARNING: Filesystem still has errors **********

/dev/sdb1: 901043/61054976 files (0.4% non-contiguous), 54639880/244189941 blocks

[编辑] 添加了请求的输出smartctl

mark@mark:~$ sudo smartctl --all /dev/sda5; sudo smartctl --all /dev/sdb1
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.18.0-15-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     KINGSTON SUV400S37240G
Serial Number:    50026B776B003933
LU WWN Device Id: 0 550380 440010000
Firmware Version: 0C3J96R9
User Capacity:    240,057,409,536 bytes [240 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Form Factor:      M.2
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   Unknown(0x0ffe), ATA8-ACS T13/1699-D revision 6
SATA Version is:  SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is:    Thu Feb 28 11:30:37 2019 CET
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:  (0x00) Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
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:        (    5) seconds.
Offline data collection
capabilities:            (0x71) SMART execute Offline immediate.
                    No Auto Offline data collection support.
                    Suspend Offline collection upon new
                    command.
                    No 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:    (   5) minutes.
Conveyance self-test routine
recommended polling time:    (   0) minutes.
SCT capabilities:          (0x003d) SCT Status supported.
                    SCT Error Recovery Control supported.
                    SCT Feature Control supported.
                    SCT Data Table supported.

SMART Attributes Data Structure revision number: 48
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   100   100   000    Pre-fail  Always       -       0
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  9 Power_On_Hours          0x0032   100   100   000    Old_age   Always       -       4502
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       496
100 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       915296
101 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       198848
170 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
171 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
172 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       0
174 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       9
175 Program_Fail_Count_Chip 0x0032   100   100   000    Old_age   Always       -       0
176 Erase_Fail_Count_Chip   0x0032   100   100   000    Old_age   Always       -       0
177 Wear_Leveling_Count     0x0032   100   100   000    Old_age   Always       -       269
178 Used_Rsvd_Blk_Cnt_Chip  0x0002   100   100   000    Old_age   Always       -       0
180 Unused_Rsvd_Blk_Cnt_Tot 0x0002   100   100   000    Old_age   Always       -       1194
183 Runtime_Bad_Block       0x0032   100   100   000    Old_age   Always       -       4
187 Reported_Uncorrect      0x0033   100   100   000    Pre-fail  Always       -       0
194 Temperature_Celsius     0x0022   027   100   000    Old_age   Always       -       27 (Min/Max 20/35)
195 Hardware_ECC_Recovered  0x0032   100   100   000    Old_age   Always       -       0
196 Reallocated_Event_Count 0x0032   100   100   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   100   100   000    Old_age   Always       -       0
199 UDMA_CRC_Error_Count    0x0012   100   100   000    Old_age   Always       -       0
201 Unknown_SSD_Attribute   0x0032   100   100   000    Old_age   Always       -       0
204 Soft_ECC_Correction     0x0032   100   100   000    Old_age   Always       -       0
231 Temperature_Celsius     0x0032   100   100   000    Old_age   Always       -       0
233 Media_Wearout_Indicator 0x0032   100   100   000    Old_age   Always       -       1575
234 Unknown_Attribute       0x0032   100   100   000    Old_age   Always       -       920
241 Total_LBAs_Written      0x0032   100   100   000    Old_age   Always       -       1374
242 Total_LBAs_Read         0x0032   100   100   000    Old_age   Always       -       1456
250 Read_Error_Retry_Rate   0x0032   100   100   000    Old_age   Always       -       0

SMART Error Log Version: 0
No Errors Logged

SMART Self-test log structure revision number 0
Warning: ATA Specification requires self-test log structure revision number = 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 0
Note: revision number not 1 implies that no selective self-test has ever been run
 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
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.18.0-15-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Western Digital Red
Device Model:     WDC WD10EFRX-68FYTN0
Serial Number:    WD-WCC4J4TC3CEE
LU WWN Device Id: 5 0014ee 2b8acbc22
Firmware Version: 82.00A82
User Capacity:    1,000,204,886,016 bytes [1.00 TB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    5400 rpm
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: 6.0 Gb/s)
Local Time is:    Thu Feb 28 11:30:37 2019 CET
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:  (0x00) Offline data collection activity
                    was never started.
                    Auto Offline Data Collection: Disabled.
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:        (13500) 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.
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:    ( 154) minutes.
Conveyance self-test routine
recommended polling time:    (   5) minutes.
SCT capabilities:          (0x303d) 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   137   136   021    Pre-fail  Always       -       4141
  4 Start_Stop_Count        0x0032   100   100   000    Old_age   Always       -       502
  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   094   094   000    Old_age   Always       -       4497
 10 Spin_Retry_Count        0x0032   100   100   000    Old_age   Always       -       0
 11 Calibration_Retry_Count 0x0032   100   100   000    Old_age   Always       -       0
 12 Power_Cycle_Count       0x0032   100   100   000    Old_age   Always       -       502
192 Power-Off_Retract_Count 0x0032   200   200   000    Old_age   Always       -       11
193 Load_Cycle_Count        0x0032   200   200   000    Old_age   Always       -       564
194 Temperature_Celsius     0x0022   113   109   000    Old_age   Always       -       30
196 Reallocated_Event_Count 0x0032   200   200   000    Old_age   Always       -       0
197 Current_Pending_Sector  0x0032   200   200   000    Old_age   Always       -       0
198 Offline_Uncorrectable   0x0030   100   253   000    Old_age   Offline      -       0
199 UDMA_CRC_Error_Count    0x0032   200   200   000    Old_age   Always       -       0
200 Multi_Zone_Error_Rate   0x0008   100   253   000    Old_age   Offline      -       0

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged.  [To run self-tests, use: smartctl -t]

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
    5        0        0  Not_testing
Selective self-test flags (0x0):
  After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

答案1

已安装的卷不“干净”,这绝对正常。只有未安装的卷(或以只读方式安装的卷)才应该是“干净的”。您的文件系统很可能没有丝毫问题。

从手册页中:

请注意,一般来说,在已挂载的文件系统上运行 e2fsck 并不安全。唯一的例外是如果指定了 -n 选项,并且 -c、-l 或 -L 选项不是指定。然而,即使这样做是安全的,如果文件系统已挂载,则 e2fsck 打印的结果无效。如果 e2fsck 询问您是否应该检查已安装的文件系统,唯一正确的答案是“否”。只有真正知道自己在做什么的专家才会考虑以其他方式回答这个问题。

从其他介质(如 USB 拇指驱动器)启动时检查并修复您的文件系统。在安装磁盘时检查磁盘毫无意义,并且 fsck 输出没有任何意义

答案2

简单的:

  1. 下载Ubuntu再次,
  2. 将其刻录到 USB / DVD / BlueRay
  3. 打开终端并运行:

    fsck -vcf dev/<disk>
    

    然后对要修复的每个错误按“y”。

  4. 然后定位坏块:

    badblocks -v /dev/<disk>
    

如果一切顺利,所有错误都应该消失。如果没有,请运行:

smartctl --all /dev/<disk>

然后它就会显示你的磁盘可能已经坏了。

相关内容