登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Q超越兔子的蜗牛O--逸云沙鸥Linux

飘飘何所似,天地一沙鸥;落霞与孤鹜齐飞,秋水共长天一色~~

 
 
 

日志

 
 

Ubuntu Grub2 修复Grub2方法  

2010-08-25 00:46:12|  分类: Ubuntu笔记 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

    Recover Grub 2 via LiveCD

    • First, grab a copy of the latest Ubuntu LiveCD and boot it.

    • Open a terminal and type
  • ----------------------------------------quick recovery begin-----------------------
  • $ sudo fdisk -l
  • $ sudo mount /dev/sda1 /mnt ##注意使用 你的 root分区所在的位置,也就是 / 所在的分区,可以使用 Ubuntu自带的磁盘实用工具查看
  • $ sudo mount /dev/sda2 /mnt/boot ##如果有专用的启动分区的话 挂载它
  • $ sudo mount --bind /dev /mnt/dev #这3个 比较必要,参数不用改
    $ sudo mount --bind /proc /mnt/proc
    $ sudo mount --bind /sys /mnt/sys
  • $ sudo chroot /mnt
  • # update-grub #已经是root了
  • # grub-install --recheck /dev/sda #一般一块硬盘的话,不用改了
  • # reboot #重启 就可以了
  • --------------------------------quick end--------------------------

    $ sudo fdisk -l

    • Now, you need to remember which device listed is your linux distribution, for reference, /dev/sda1 will be used. Now we need to mount the filesystem to /mnt

    $ sudo mount /dev/sda1 /mnt

    • If you have /boot on a separate partition, that need's to be mounted aswell. For reference, /dev/sda2 will be used.

    $ sudo mount /dev/sda2 /mnt/boot

    • If you have /var on a separate partition, that need's to be mounted aswell. For reference, /dev/sda3 will be used.

    $ sudo mount /dev/sda3 /mnt/var Make sure you don't mix these up, pay attention to the output of FDISK

    • Now mount the rest of your devices and some other things needed in the chroot

    $ sudo mount --bind /dev /mnt/dev
    $ sudo mount --bind /proc /mnt/proc
    $ sudo mount --bind /sys /mnt/sys

    • Now chroot into your system

    $ sudo chroot /mnt

    $ update-grub

    You should be chroot'd into your system as root, you can now run commands as root, without the need for sudo.

    • Now you need to edit the /etc/default/grub file to fit your system

    $ nano /etc/default/grub

    • When that is done you need to run update-grub to create the configuration file. If you have a separate /boot partition you need to mount it first!

    $ update-grub

    • To install GRUB 2 to the MBR, next you need to run grub-install /dev/sda

    $ grub-install /dev/sda

    • If you encounter any errors, try grub-install --recheck /dev/sda

    $ grub-install --recheck /dev/sda

    • Press Ctrl+D to exit out of the chroot.
    • Once you exit back to your regular console, undo all the mounting, first the /dev and others

    $ sudo umount /mnt/dev
    $ sudo umount /mnt/sys
    $ sudo umount /mnt/proc

    • Now you can unmount the root system. (But if you have a separate boot partition which you mounted earlier, you have to unmount this first, or you will get a "device busy" error message.)

    $ sudo umount /mnt

    • And you should be free to restart your system right into GRUB 2 and then into your system installation.

    If you had alternate OS entries, update-grub might say "Cannot find list of partitions!". Ignore it and continue - once you can boot into your linux installation, do so and then rerun update-grub and grub-install /dev/sda as root.

    Restore GRUB2 - Recovering from a Windows XP / Vista / 7 Reinstallation

    Fire up a terminal from the Live CD for Ubuntu 10.04.
    $ sudo fdisk -l (Note the partition number on which Linux resides)
    $ sudo mount /dev/sdaX /mnt (Replace X with the partition number housing Linux)
    $ sudo grub-install --root-directory=/mnt/ /dev/sda
    $ sudo update-grub
    $ sudo reboot

    Credits to
    http://mundogeek.net/archivos/2009/12/08/recuperar-grub-2/ for the enlightening post & 
    http://www.webupd8.org/2009/12/how-to-recover-grub2-linux.html for the awesome translation.

    重点推荐 Ubuntu Grub2 完全手册:https://help.ubuntu.com/community/Grub2#Reinstalling%20GRUB%202

  评论这张
 
阅读(2662)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018