如何在启动前或重新启动时 fsck 根文件系统

如何在启动前或重新启动时 fsck 根文件系统

今天,我检查了运行 Linux Mint 17.3 Cinnamon 的桌面站,并对具有 Ext4 文件系统的根分区进行了文件系统检查,如下所示:

# fsck.ext4 -fn /dev/sdb2

问题是,在所有计算机上我都看到与此类似的内容:

e2fsck 1.42.9 (4-Feb-2014)
Warning!  /dev/sdb2 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
Pass 1: Checking inodes, blocks, and sizes
Deleted inode 524292 has zero dtime.  Fix? no

Inodes that were part of a corrupted orphan linked list found.  Fix? no

Inode 524293 was part of the orphaned inode list.  IGNORED.
Inode 524294 was part of the orphaned inode list.  IGNORED.
Inode 524299 was part of the orphaned inode list.  IGNORED.
Inode 524300 was part of the orphaned inode list.  IGNORED.
Inode 524301 was part of the orphaned inode list.  IGNORED.
Inode 524302 was part of the orphaned inode list.  IGNORED.
Inode 524310 was part of the orphaned inode list.  IGNORED.
Inode 524321 was part of the orphaned inode list.  IGNORED.
Inode 524322 was part of the orphaned inode list.  IGNORED.
Inode 524325 was part of the orphaned inode list.  IGNORED.
Inode 2492565 was part of the orphaned inode list.  IGNORED.
Inode 2622677 was part of the orphaned inode list.  IGNORED.
Inode 2622678 was part of the orphaned inode list.  IGNORED.
Inode 2883748 was part of the orphaned inode list.  IGNORED.
Inode 2884069 was part of the orphaned inode list.  IGNORED.
Inode 2885175 was part of the orphaned inode list.  IGNORED.
Pass 2: Checking directory structure
Entry 'Default_keyring.keyring' in /home/vlastimil/.local/share/keyrings (2495478) has deleted/unused inode 2498649.  Clear? no

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

Pass 5: Checking group summary information
Block bitmap differences:  -(34281--34303) -11650577 -(11650579--11650580) -11650591 -(11650594--11650595) -(13270059--13270073) -(13272582--13272583) -(20542474--20542475) +(26022912--26023347) -(26029568--26030003)
Fix? no

Free blocks count wrong (14476802, counted=14476694).
Fix? no

Inode bitmap differences:  -(524292--524294) -(524299--524302) -524310 -(524321--524322) -524325 +2491790 -2492565 -2498649 -(2622677--2622678) -2883748 -2884069 -2885175
Fix? no

Free inodes count wrong (7371936, counted=7371916).
Fix? no


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

/dev/sdb2: 443232/7815168 files (0.1% non-contiguous), 16757502/31234304 blocks

我尝试过的:

# touch /forcefsck

这会导致启动时持续检查 2-3 秒。显然没有修复任何东西。

这很可能是因为我的根文件系统在某种程度上是干净的。

# fsck.ext4 -n /dev/sdb2

e2fsck 1.42.9 (4-Feb-2014)
Warning!  /dev/sdb2 is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
/dev/sdb2: clean, 443232/7815168 files, 16757502/31234304 blocks

由于除了 之外,我几乎找不到任何用于启动时文件系统检查的内容sudo touch /forcefsck,因此我尝试了以下步骤:

  1. echo u > /proc/sysrq-trigger
  2. umount /dev/sdb2
  3. fsck -fy /dev/sdb2

这确实表明它已修复,以确保我fsck再次运行而没有错误。但是,一旦我重新启动,它们就会回来。我现在很困惑。请不要进行诸如“创建闪存驱动器并从中启动......”之类的指示。我想要一个在重新启动时或重新启动之前的解决方案,而不需要从某些闪存驱动器启动。谢谢。

答案1

首先,对已安装的文件系统进行 fsck 是预期的来产生错误。文件系统不一致,因为日志尚未重播(也未完全卸载),并且您无法重播日志,因为这(与任何其他更改一样)会损坏文件系统。如果您使用 LVM,则可以拍摄快照并对快照进行 fsck。

如果你使用 SSD,fsck速度会相当快。您还可以尝试使用tune2fs -C将安装计数设置为高于最大值(可以从 获取dumpe2fs -h)。

touch /forcefsck 应该管用

编者注:

  1. touch /forcefsck不起作用。

  2. 请参阅这个答案以获得清晰的证据和解决方案。

答案2

Linux Mint 17.3 基于 Ubuntu 14.04。

我建议您尝试使用标准的恢复菜单来fsck驱动器。

Ubuntu 恢复菜单

分步指南取自 Mint 18.3,因此可能略有不同,因为该版本基于 Ubuntu 16.04:

  1. 在 GRUB 菜单中选择 Linux Mint 的高级选项...

  2. 您会看到 3 个选项,其中之一有(恢复模式)最后,选择这个。

  3. 现在,您可以选择标题为描述的选项fsck

    检查所有文件系统

相关内容