Linux
如何在引導之前或重新引導時 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
,我嘗試了以下步驟:
echo u > /proc/sysrq-trigger
umount /dev/sdb2
fsck -fy /dev/sdb2
這確實表明它已經修復,以確保我
fsck
再次執行沒有錯誤。但是,一旦我重新啟動,它們就會回來。我現在很困惑。請不要像“創建一個快閃記憶體驅動器並從它啟動然後……”這樣的指示。我想要一個在重新啟動時或在重新啟動之前沒有從某些快閃記憶體驅動器啟動的解決方案。謝謝你。
首先,fsck’ing 掛載的文件系統預計會產生錯誤。文件系統不一致,因為日誌沒有被重放(也沒有被完全解除安裝),並且你不能重放日誌,因為(像任何其他更改一樣)會損壞文件系統。如果您使用的是 LVM,則可以拍攝快照並 fsck 快照。
如果您使用的是 SSD,
fsck
則可能會非常快。您也可以嘗試使用tune2fs -C
將安裝計數設置為高於最大值(您可以從中獲得dumpe2fs -h
)。
touch /forcefsck
應該工作。編者註:
touch /forcefsck
不起作用。- **請參閱此答案**以獲得清晰的證據和解決方案。