page counter next up previous contents
Next: About this document ... Up: 開機流程與系統服務 Previous: 開機過程的問題解決   Contents

無法開機問題解決

  1. MBR 或 /boot 開機資料損壞,因而無法開機,必須使用救命光碟開機來修復。不過也可以使用其他 Linux 媒體開機來進行修復。
  2. 將要修復的硬碟原根目錄 /dev/mapper/dywhd2-root 掛載起來。
    [root@dywH ~]# mount /dev/mapper/dywhd2-root /mnt/root/
    
  3. 安裝 grub 到硬碟 /dev/sdg 的分割區 /dev/sdg1, 注意要指定其根目錄為 /mnt/root,否則會以目前的系統的根錄為開機根目錄。
    [root@dywH ~]# grub-install --root-directory=/mnt/root/ /dev/sdg1
    Probing devices to guess BIOS drives. This may take a long time.
    /dev/mapper/../dm-7 does not have any corresponding BIOS drive.
    
  4. 檢查 /dev/mapper 下的 dm-7 是 /dev/mapper/dywhd2-root,就是要修復的開機根目錄。
    [root@dywH ~]# ll /dev/mapper/
    total 0
    crw-rw----. 1 root root 10, 58 Apr 13 06:40 control
    lrwxrwxrwx. 1 root root      7 Apr 13 06:56 dywhd2-home -> ../dm-5
    lrwxrwxrwx. 1 root root      7 Apr 13 06:56 dywhd2-pub -> ../dm-6
    lrwxrwxrwx. 1 root root      7 Apr 13 06:56 dywhd2-root -> ../dm-7
    lrwxrwxrwx. 1 root root      7 Apr 13 06:56 dywhd2-swap -> ../dm-4
    lrwxrwxrwx. 1 root root      7 Apr 13 06:40 vg_dywH-lv_home -> ../dm-2
    lrwxrwxrwx. 1 root root      7 Apr 13 06:40 vg_dywH-lv_pub -> ../dm-3
    lrwxrwxrwx. 1 root root      7 Apr 13 06:40 vg_dywH-lv_root -> ../dm-0
    lrwxrwxrwx. 1 root root      7 Apr 13 06:40 vg_dywH-lv_swap -> ../dm-1
    [root@dywH ~]# mount /dev/sdg1 /mnt/root/boot/
    [root@dywH ~]# grub-install --root-directory=/mnt/root/ /dev/sdg1
    /dev/sdg1 does not have any corresponding BIOS drive.
    
  5. 因為 /dev/mapper/dywhd2-root 目錄下沒有將 /boot 目錄開機資料,所以將 /boot 目錄掛載起來。
    [root@dywH ~]# mount /dev/sdg1 /mnt/root/boot/
    
  6. 再執行 grub-install,如果還有一樣的訊息,就加上 -recheck 選項重新檢查開機區。
    [root@dywH ~]# grub-install --recheck --root-directory=/mnt/root/ /dev/sdg1
    Probing devices to guess BIOS drives. This may take a long time.
    Installation finished. No error reported.
    This is the contents of the device map /mnt/root//boot/grub/device.map.
    Check if this is correct or not. If any of the lines is incorrect,
    fix it and re-run the script `grub-install'.
    
    (fd0)	/dev/fd0
    (hd0)	/dev/sda
    (hd1)	/dev/sdg
    
  7. 再執行 grub-install,不加上 -recheck 選項,以下為 grub 安裝到 /mnt/root 成功的訊息。
    [root@dywH ~]# grub-install --root-directory=/mnt/root/ /dev/sdg1
    Installation finished. No error reported.
    This is the contents of the device map /mnt/root//boot/grub/device.map.
    Check if this is correct or not. If any of the lines is incorrect,
    fix it and re-run the script `grub-install'.
    
    (fd0)	/dev/fd0
    (hd0)	/dev/sda
    (hd1)	/dev/sdg
    
  8. grub 安裝好後如果還是無法開機,就要檢查開機選單的資料是否正確?要注意的有:
    1. 指定的 kernel 及 initrd 是否確實在 /mnt/root/boot/ 目錄下?
    2. 指定根目錄 root=... 是否正確?
    3. rd_LVM_LV=dywhd2/root 中的 dywhd2 為 vg 名稱,root 則為其 lv 的名稱;rd_LVM_LV=dywhd2/swap 一樣的意義, vg dywhd2 下有 lv 名為 swap。檢查這些 vg, lv 是否正確?
    [root@dywH ~]# grep ^title -A4 /mnt/root/boot/grub/grub.conf
    title De-Yu Wang (2.6.32-358.18.1.el6.x86_64)
    	root (hd0,0)
    	kernel /vmlinuz-2.6.32-358.18.1.el6.x86_64 ro \
    root=/dev/mapper/dywhd2-root \
    rd_LVM_LV=dywhd2/root rd_LVM_LV=dywhd2/swap \
    rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 \
    SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc \
    KEYTABLE=us crashkernel=auto rhgb quiet
    	initrd /initramfs-2.6.32-358.18.1.el6.x86_64.img
    
  9. 依照以上步驟檢查及修復,硬碟 /dev/sdg 就可開機了,不需要燒救命光碟一樣可以解決。



2015-04-13