1. 程式人生 > >修復損壞linux 檔案系統

修復損壞linux 檔案系統

revised by woflman 2007.08.05今天的我們早上我的伺服器無法啟動,停在檢查mail.wofman.com/var filesystem bad ,我的mail檔案在此目錄下;Bad magic number in super_block while trying to open /var***An error occured during the file system check*** Dropping you to a shell; the system will reboot *** when you leave the shell.Press enter for maintenance(or type Control-D to continue):輸入admai pass 後進入 (Repair filesystem)#檢視/etc/fstab 沒有錯誤,執行fsck -p /var 執行完畢有下面提示:/dev/sda3 contains a file system with errors, check forced./dev/sda3: Inodes that were part of a corrupted orphan linked list found./dev/sda3: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.(i.e., without -a or -p options)執行fsck.ext3 -p /dev/sda3 ;未能修復執行fsck.ext3 -y /dev/sda3 ; repair ok ;注意在修復其它filesystem時要umount掉執行該命令。檔案系統--fsck指令:fsck 使用許可權 : 超級使用者 使用方式 : fsck --helpfsck 1.35 (28-Feb-2004)fsck.ext3: invalid option -- hUsage: fsck.ext3 [-panyrcdfvstDFSV] [-b superblock] [-B blocksize][-I inode_buffer_blocks] [-P process_inode_size][-l|-L bad_blocks_file] [-C fd] [-j ext-journal][-E extended-options] deviceEmergency help:-p Automatic repair (no questions) ;自動修復-n Make no changes to the filesystem ;模擬修復-y Assume "yes" to all questions ;所有的問題都回答yes-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引用網上的一個例子 : 問題: SLES8 在mount盤陣的時候,出現server1:/ # mount /dev/sde1 /foomount: wrong fs type, bad option, bad superblock on /dev/sde1,or too many mounted file systems的問題。請問這種問題怎麼能解決呢?回答:這個錯誤資訊標識 /dev/sde1 裝置上的 ext3 檔案系統的超級塊損壞了,ext3 檔案系統的元資料儲存在超級塊中。ext3 檔案系統還有一些備份的超級塊,可以嘗試用備份的超級塊載入 ext3 檔案系統和修復 ext3 檔案系統。備份的超級塊資訊可以通過以下命令獲得,這個命令模擬 ext3 檔案系統建立時的動作並打印出備份超級塊的位置,給出的位置預設是以4k為單位的,mount 在使用時需要為它提供以1k為單位的偏移,需要乘4:注意!!!!!一定要使用'-n'作為引數模擬 ext3 檔案系統的建立而不是真的建立 ext3 檔案系統# mkfs.ext3 -n /dev/hda7mke2fs 1.38 (30-Jun-2005)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)2198880 inodes, 4393738 blocks219686 blocks (5.00%) reserved for the super userFirst data block=0135 block groups32768 blocks per group, 32768 fragments per group16288 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000使用備份的超級塊來載入 ext3 檔案系統的命令:語法: mount.ext3 -o sb=n # mount.ext3 -o sb=131072 /dev/hda7 /media/hda7使用備份的超級塊來修復 ext3 檔案系統的命令語法:fsck.ext3 -b superblock # fsck.ext3 -b 32768 /dev/hda7