LINUX 文件系統損壞後遠程修復方案

****************************************************
  切記使用fsck一定要先卸載分區,否則後果自負
****************************************************
   【一】
  
     是出現經常非法關機,斷電,導致文件系統不連續,而在強制檢查後不能通過的情況,系統會進入一個修復(repair)模式,
需要遠程協助開啓network和sshd服務,然後 cd /boot; umount / ;  fsck -y /dev/sda3(假設根目錄分區爲sda3)
   這裏可能會有一些不連續或者部分損壞的文件被系統擱置到/lost+found目錄下,都以#開頭,以節點命名的目錄,
需要手動恢復,恢復步驟自行到網上查詢,需要確認原來的目錄結構
   【二】
    另外一種比較嚴重,同樣因爲某些原因,例如升級內核,例如頻繁斷電,導致啓動到內核後,出現類似以下錯誤,
              
               Boot error:
                -----------------------------------------------------
               
                root (hd0,0)
                Filesystem type is ext2fs, partition type 0x83
                kernel /vmlinuz-2.6.15.6 ro root=LABLE=/ rhgb quiet
                   [Linux-bzImage, setup=0x1e00, size=0x1807f8]
                initrd /initrd-2.6.15.6.img
                   [Linux-initrd @ 0x37f82000, 0x6d283 bytes]
               
                Uncompressing Linux... Ok, booting the kernel.
                Red Hat nash version 4.1.18 starting
                mkrootdev: label / not found
                umount /sys failed:16
                mount: error 2 mounting ext3
                mount: error 2 mounting none
                switchroot: mount failed: 22
                umount /initrd/dev failed: 2
                Kernel panic - not syncing: Attempted to kill init!
                -------------------------------------------------------
            a.  遠程協助,進入grub後,能否檢測到系統完整的 LINUX分區,如果分區完整,並且進一步分區下的目錄結構和文件初步完整,OK
                將 kernel 後的 root=LABEL=/ 改成 root=/dev/hda3 或者 root=/dev/sda3 (根目錄所在分區,我一般分爲sda3)
                應該可以順利進入系統,然後參考 mklabel 命令,給根分區打上LABEL,或者修改grub.conf,將標籤項改成用分區表示,然後grub-install ....
                進行grub安裝
               
            b. 遠程協助,進入grub後,只能檢測到/boot所在分區,而root分區不完整,只能通過進入rescue模式,或者用live cd, 利用fsck了,
               這裏提醒一下,儘量別用帶x-window的LIVECD,這種垃圾盤把我害慘了.
               另外儘量平時能備些CD的盤,大家用習慣了DVD,可是這次的情況就是服務器上沒有DVD,全是CD,又找不來移動DVD
               只能通過網絡PXE來完成了.....
           
            c. 把磁盤掛載到其他的主機上個別分區如果掛載不上提示指定文件系統的話我們可以通過如下步驟來恢復數據:
            恢復數據實踐步驟!!!

  1.複製磁盤
  dd if=源盤分區  of=目標盤分區 (最好一模一樣大小) ,例如目標盤分區爲/dev/sdb3
  2.
  mkfs.ext3 -n /dev/sdb3   (一定要有-n,切記)  記住最後一個數字值
  3.
  screen -S check
  fsck -b  XXXX /dev/sdb3 -y
  XXX爲第二部裏最後一個數字
  開始檢測,不用管,按 Ctrl+a -> d ,切換到後臺,等掃描完, fsck -y /dev/sdb3 確認。
  4.
  mount /dev/sdb3 /mnt
   【三】
  
       至於連grub都進不去的,不用說了,遠程協助,直接進入live cd 或者 rescue模式,先看分區是否完整,如果完整,直接用grub-install.......,具體使用參考網絡
       如果分區不完整,那隻能用數據恢復軟件,數據重要的話就花點時間找吧,或者花點money,不重要的話直接reinstall吧,嘎嘎
     
     
     
     
 
 
 
     
 另外給一個網上的參考
 ================================================================= 
 
                  Boot error:
                 
                  -----------------------------------------------------
                 
                  root (hd0,0)
                  Filesystem type is ext2fs, partition type 0x83
                  kernel /vmlinuz-2.6.15.6 ro root=LABLE=/ rhgb quiet
                     [Linux-bzImage, setup=0x1e00, size=0x1807f8]
                  initrd /initrd-2.6.15.6.img
                     [Linux-initrd @ 0x37f82000, 0x6d283 bytes]
                 
                  Uncompressing Linux... Ok, booting the kernel.
                  Red Hat nash version 4.1.18 starting
                  mkrootdev: label / not found
                  umount /sys failed:16
                  mount: error 2 mounting ext3
                  mount: error 2 mounting none
                  switchroot: mount failed: 22
                  umount /initrd/dev failed: 2
                  Kernel panic - not syncing: Attempted to kill init!
                  -------------------------------------------------------
                 
                  蒐集了網上提到的解決方法:
                 
                  A. 修改grub.conf ==>  root=305
                  B. 修改grub.conf ==>  root=/dev/sdax
                  C. 修改grub.conf ==>  root=LABLE=/1
                  D. disable SMP
                  E. build-in ext3/SATA/ATA/SCSI
                  F. 根據現有/etc/modprobe,使用mkinitrd手動生成initrd-2.6.15.6.img
                 
                  均無法解決,當前系統提示:
                 
                  root (hd0,0)
                  Filesystem type is ext2fs, partition type 0x83
                  kernel /vmlinuz-2.6.15.6 ro root=LABLE=/ rhgb quiet
                     [Linux-bzImage, setup=0x1e00, size=0x1807f8]
                  initrd /initrd-2.6.15.6.img
                     [Linux-initrd @ 0x37f82000, 0x6d283 bytes]
                 
                  Uncompressing Linux... Ok, booting the kernel.
                  Red Hat nash version 4.1.18 starting
                  mount: error 6 mounting ext3
                  mount: error 2 mounting none
                  switchroot: mount failed: 22
                  umount /initrd/dev failed: 2
                  Kernel panic - not syncing: Attempted to kill init!
                  -------------------------------------------------------------------
                 
                  可能性:
                 
                  1、scsi驅動不正確;
                 
                  2、系統在沒有完成設備檢測前就開始掛載分區;
                 
                  3、多硬盤引導。
 
 
 
四。
switching to new root
exec of init (/sbin/init/)failed!!!:2
umount /initrd/dev failed:2
kernel panic -not syncing:Attempeed to kill init !
先進入修復模式,然後看一下chroot /mnt/sys(後面的忘了,tab一下)  能不能將根掛起來,如果掛不起來說明你的fstab都有問題,
如果是這樣,mkdir test建立一個test目錄,再用e2label 找到你的根分區對應的設備號如找到爲/dev/hda2 ,然後使用mount /dev/hda2 test
將根掛到剛纔新建的test目錄下,這樣進如test目錄就可以對fstab進行修改了,順便看看inittab文件是否正確,一般這樣就可以解決問題了.
如果還是不行,就將boot分區中的內容刪掉,再重新生成.一般只要不是超高難度問題,這樣的方法都可以解決.估計你可能還是分區的fstab表對應有問題

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章