SOPs: How to repair a broken Superblock ================================================================================= Issue description --------------------------------------------------------------------------------- 執行環境: Zorin OS 17.1 Kernel: 6.5.0-44-generic 在OS底下進行實驗時,不慎將主要硬碟的Superblock(超級區塊)塗改,導致無法讀取,進而使得系統當機,無法進入OS Root cause analysis --------------------------------------------------------------------------------- 文件系統(filesystem)分區(partition)結構如下:  * Bootblock (啟動區塊,放置開機管理檔;一般來說就算該分區不裝有OS一樣會保留這個block) * Superblock (超級區塊,紀錄整個文件系統的相關資訊,包含inode和block的總數,已使用量,剩餘量等) * inode (index node,目錄節點,紀錄文件系統中,各項文件的修改時間、權限、實際存放的資料區塊位置等) * Datablocks (資料區塊,實際資料存放在此) 根據上圖結構可知,一旦失去superblock,便會因為無法得知整個分區的相關資訊,進而無法使用分區內部資料 Solution --------------------------------------------------------------------------------- ### 使用備份分割表修復 因為是在ubuntu下(文件系統:ext series),所以使用"e2fs"指令來查找備份分割表並還原至主要分割表 Command:`sudo mke2fs -n /dev/"target device"/`  由上圖可知,superblock分別備份在以下區塊: * 32768 * 98304 * 163840 * 229376 * 294912 * 819200 * 884736 * 1605632 * 2654208 * 4096000 任選其中一塊,還原至superblock即可: Command:`e2fsck -f -b 98304 -y /dev/"target device"/` 最後執行硬碟檢查: Command: `e2fsck -c -f -y /dev/"target divice"/` 只要回報錯誤"error"是0,即是修復成功,如不成功,再使用其他block做還原即可 Ref. --------------------------------------------------------------------------------- [can NOT boot-in OS because broken superblock](https://forum.suse.org.cn/t/superblock/2626) [Repair a broken Superblock](https://linuxexpresso.wordpress.com/2010/03/31/repair-a-broken-ext4-superblock-in-ubuntu/) [repair superblock](https://askubuntu.com/questions/1376645/retrieve-data-from-disk-after-dd) [Detatils about superblock & filesystem](https://blog.csdn.net/cunjiu9486/article/details/109072864#:~:text=%E8%B6%85%E7%BA%A7%E5%9D%97(Super%20Block)&text=%E8%B6%85%E7%BA%A7%E5%9D%97%E6%98%AF%E5%85%83%E6%95%B0%E6%8D%AE,%E5%85%83%E6%95%B0%E6%8D%AE%E7%AD%89%E7%9A%84%E4%BF%A1%E6%81%AF%E3%80%82) [How linux OS excute filesystem](https://blog.csdn.net/hawava/article/details/116199112) [disk physics manual](https://blog.csdn.net/weixin_47187147/article/details/126908793?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-126908793-blog-109072864.235^v43^pc_blog_bottom_relevance_base6&spm=1001.2101.3001.4242.1&utm_relevant_index=3) [ext filesystem](https://cs.pynote.net/hd/hdisk/202306132/)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up