Filesystems
修復 EXT4-fs 錯誤幾何(塊數超過設備大小)
我有一個微型 SD 卡,它有一個 FAT32 分區和一個 EXT4 分區。EXT4 分區將不再掛載。dmesg 顯示以下錯誤:
EXT4-fs (sdb2): bad geometry: block count 2199023779840 exceeds size of device (524288 blocks)
我用Google搜尋過,但仍然不完全理解問題出在哪裡(在分區表中?文件系統?)也不知道如何解決它。我嘗試了多種解決方案:
- 使用testdisk寫分區表
- 使用 fsck 從備份中恢復超級塊(我已經嘗試了所有這些)。例如
fsck.ext4 -b 163840 -B 4096 /dev/sdb2
- 用於
fsck -cc
檢查壞塊- 使用 resize2fs 設置分區的大小。輸出:
The combination of flex_bg and !resize_inode features is not supported by resize2fs.
當我執行 fsck 時,它會出現一堆錯誤(下面的完整輸出),它聲稱可以修復這些錯誤。但是,如果我再次執行它,它每次都會再次顯示相同的錯誤。
如何解決錯誤的幾何問題並使我的文件系統再次可掛載?這怎麼發生的?
fsck 輸出:
e2fsck 1.42 (29-Nov-2011) One or more block group descriptor checksums are invalid. Fix<y>? yes Group descriptor 0 checksum is invalid. FIXED. Group descriptor 1 checksum is invalid. FIXED. Group descriptor 2 checksum is invalid. FIXED. Group descriptor 3 checksum is invalid. FIXED. Group descriptor 4 checksum is invalid. FIXED. Group descriptor 5 checksum is invalid. FIXED. Group descriptor 6 checksum is invalid. FIXED. Group descriptor 7 checksum is invalid. FIXED. Group descriptor 8 checksum is invalid. FIXED. Group descriptor 9 checksum is invalid. FIXED. Group descriptor 10 checksum is invalid. FIXED. Group descriptor 11 checksum is invalid. FIXED. Group descriptor 12 checksum is invalid. FIXED. Group descriptor 13 checksum is invalid. FIXED. Group descriptor 14 checksum is invalid. FIXED. Group descriptor 15 checksum is invalid. FIXED. /dev/sdb2 contains a file system with errors, check forced. 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 for group #0 (24465, counted=24466). Fix<y>? yes Free blocks count wrong for group #2 (4788, counted=5812). Fix<y>? yes Free blocks count wrong for group #3 (8710, counted=8881). Fix<y>? yes Free blocks count wrong for group #8 (5682, counted=22066). Fix<y>? yes Free blocks count wrong (299742, counted=317322). Fix<y>? yes Inode bitmap differences: -(8193--8194) -8197 -8208 -(8225--8226) -8229 -(8240--8241) -(8257--8258) -8261 -8272 -8274 -(8289--8290) -8293 -(8304--8306) -(8321--8322) -8325 -8336 -8339 -16387 -16389 -16400 -16419 -16421 -(16432--16433) -16451 -16453 -16464 -16466 -16483 -16485 -(16496--16498) -16515 -16517 -16528 -16531 -24577 -24579 -24581 -24592 -24609 -24611 -24613 -(24624--24625) -24641 -24643 -24645 -24656 -24658 -24673 -24675 -24677 -(24688--24690) -24705 -24707 -24709 -24720 -24723 -(32770--32771) -32773 -32784 -(32802--32803) -32805 -(32816--32817) -(32834--32835) -32837 -32848 -32850 -(32866--32867) -32869 -(32880--32882) -(32898--32899) -32901 -32912 -32915 -(40961--40963) -40965 -40976 -(40993--40995) -40997 -(41008--41009) -(41025--41027) -41029 -41040 -41042 -(41057--41059) -41061 -(41072--41074) -(41089--41091) -41093 -41104 -41107 -(49156--49157) -49168 -(49188--49189) -(49200--49201) -(49220--49221) -49232 -49234 -(49252--49253) -(49264--49266) -(49284--49285) -49296 -49299 -57345 -(57348--57349) -57360 -57377 -(57380--57381) -(57392--57393) -57409 -(57412--57413) -57424 -57426 -57441 -(57444--57445) -(57456--57458) -57473 -(57476--57477) -57488 -57491 -65538 -(65540--65541) -65552 -65570 -(65572--65573) -(65584--65585) -65602 -(65604--65605) -65616 -65618 -65634 -(65636--65637) -(65648--65650) -65666 -(65668--65669) -65680 -65683 -(73729--73730) -(73732--73733) -73744 -(73761--73762) -(73764--73765) -(73776--73777) -(73793--73794) -(73796--73797) -73808 -73810 -(73825--73826) -(73828--73829) -(73840--73842) -(73857--73858) -(73860--73861) -73872 -73875 -(81923--81925) -81936 -(81955--81957) -(81968--81969) -(81987--81989) -82000 -82002 -(82019--82021) -(82032--82034) -(82051--82053) -82064 -82067 -90113 -(90115--90117) -90128 -90145 -(90147--90149) -(90160--90161) -90177 -(90179--90181) -90192 -90194 -90209 -(90211--90213) -(90224--90226) -90241 -(90243--90245) -90256 -90259 -(98306--98309) -98320 -(98338--98341) -(98352--98353) -(98370--98373) -98384 -98386 -(98402--98405) -(98416--98418) -(98434--98437) -98448 -98451 -(106497--106501) -106512 -(106529--106533) -(106544--106545) -(106561--106565) -106576 -106578 -(106593--106597) -(106608--106610) -(106625--106629) -106640 -106643 -114694 -114704 -114726 -(114736--114737) -114758 -114768 -114770 -114790 -(114800--114802) -114822 -114832 -114835 -122881 -122886 -122896 -122913 -122918 -(122928--122929) -122945 -122950 -122960 -122962 -122977 -122982 -(122992--122994) -123009 -123014 -123024 -123027 Fix<y>? yes Free inodes count wrong for group #0 (7803, counted=7804). Fix<y>? yes Free inodes count wrong (130683, counted=130684). Fix<y>? yes /dev/sdb2: ***** FILE SYSTEM WAS MODIFIED ***** /dev/sdb2: 388/131072 files (22.7% non-contiguous), 206966/524288 blocks
fdisk -l
輸出:Disk /dev/sdb: 16.0 GB, 16012804096 bytes 64 heads, 32 sectors/track, 15271 cylinders, total 31275008 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 Disk identifier: 0x0005ce93 Device Boot Start End Blocks Id System /dev/sdb1 * 2048 27080703 13539328 c W95 FAT32 (LBA) /dev/sdb2 27080704 31275007 2097152 83 Linux
截斷 SD 卡圖像後出現同樣的問題,其中 SD 比原始文件少幾個塊。使用 fdisk 重新分區驅動器(見上文),但仍然存在消息“超級塊中的大小與分區的物理大小不同”。在這裡找到解決方案:http ://www.linuxquestions.org/questions/linux-hardware-18/size-in-superblock-is-different-from-the-physical-size-of-the-partition-298175/
因此,在未掛載的分區上:
e2fsck -f /dev/XXX resize2fs /dev/XXX
文件系統不關心磁碟幾何;這是一個分區表問題。
我建議你做一個分區表轉儲,檢查結果並用這個轉儲覆蓋分區表。這應該更正 CHS 條目。
sfdisk -d /dev/sdx >sdx.txt cat sdx.txt sfdisk /dev/sdx <sdx.txt