Terminal

fsck 有效選項無效

  • May 13, 2017

我有一張損壞的 micro SD 卡,我不小心拔出了。我想使用fsck實用程序搜尋並修復任何錯誤。

$ umount /dev/mmcblk0
$ fsck --help
fsck from util-linux 2.29.2
fsck.ext3: invalid option -- 'h'
Usage: fsck.ext3 [-panyrcdfktvDFV] [-b superblock] [-B blocksize]
       [-l|-L bad_blocks_file] [-C fd] [-j external_journal]
       [-E extended-options] [-z undo_file] device

Emergency help:
-p                   Automatic repair (no questions)
-n                   Make no changes to the filesystem
-y                   Assume "yes" to all questions
-c                   Check for bad blocks and add them to the badblock list
-f                   Force checking even if filesystem is marked clean
-v                   Be verbose
-b superblock        Use alternative superblock
-B blocksize         Force blocksize when looking for superblock
-j external_journal  Set location of the external journal
-l bad_blocks_file   Add to badblocks list
-L bad_blocks_file   Set badblocks list
-z undo_file         Create an undo file

$ fsck /dev/mmcblk0 
fsck from util-linux 2.29.2
exfatfsck 1.2.6
Checking file system on /dev/mmcblk0.
File system version           1.0
Sector size                 512 bytes
Cluster size                128 KB
Volume size                  59 GB
Used space                   25 GB
Available space              35 GB
ERROR: unknown entry type 0x86.
ERROR: cluster 0x111ee of file 'expunged' is not allocated.
Totally 260 directories and 3182 files.
File system checking finished. ERRORS FOUND: 2.

$ fsck -p /dev/mmcblk0
fsck from util-linux 2.29.2
exfatfsck 1.2.6
fsck.exfat: invalid option -- 'p'
Usage: fsck.exfat [-V] <device>

為什麼-p選項在幫助中說它是無效的Automatic repair (no questions)?那我該如何修復我的 SD 卡呢?

在這兩種情況下查看輸出的第二行。fsck --help已使用fsck.ext3(系統上的預設設置)並顯示了對該工具有效的選項,但fsck -p /dev/mmcblk0使用exfatfsck它是因為這適合您的 SD 卡。

不幸的是exfatfsck 無法修復錯誤,它只能報告它們。所以執行

fsck /dev/mmcblk0

查看是否有任何錯誤;如果有,您將需要其他一些策略來修復文件系統:

  • 使用具有能夠修復文件系統的工具的另一個作業系統(Windows?);
  • 或在 Linux 上,將所有文件複製到其他地方並重新格式化卡。

引用自:https://unix.stackexchange.com/questions/364804