• Troubleshooting:安装Linux多系统及Grub修复


    问题:

    我的机器上现存Win7和CentOS(升级到3.6.0的linux内核),还有200多G的空间,想再装个CentOS (2.6.32内核),结果U盘安装时调换了启动顺序,安装完成后,默认启动进入CentOS (2.6.32),在几秒内按键,可进入启动选项Other,但Other就直接进Win7了。

     

     

    原因:

    CentOS(3.6.0)的grub被刷掉了。

    解决方法:

    开机后在进入CentOS(2.6.32)倒计时时随便按键,进入Grub的开机选项,按c键进入grub命令行

    grub> find /boot/grub/stage1  返回grub位置,或者用find /grub/stage1或find stage1总有一个能找到

    我返回了(hd0,4)和(hd0,6),(hd0,6)应该是现在的引导,我要恢复以前的

    grub> root (hd0,4)    注意一定要有空格

    grub> setup (hd0)    有时候会出现命令不认识的情况,需要多输入几次。

    grub> reboot

    合并多个Grub:

    这样开机选单里就会出现三个系统,分别是CentOS(3.6.0),CentOS(2.6.32),Other(Win7)。注意这个CentOS(2.6.32)并不是新装的,而是升级前的(忘了删了)。要想进入新装系统,还得root(hd0,6),setup(hd0)。这样每次都到Grub里切换太麻烦,可以把两个Grub配置文件合并。假如现在Grub是(hd0,4)进入CentOS(3.6.0)或CentOS(2.6.32),可以将(hd0,6)进入的新CentOS(2.6.32)的相关部分复制到/etc/grub.conf中,最后/etc/grub.conf内容如下:

    # grub.conf generated by anaconda
    #
    # Note that you do not have to rerun grub after making changes to this file
    # NOTICE:  You do not have a /boot partition.  This means that
    #          all kernel and initrd paths are relative to /, eg.
    #          root (hd0,4)
    #          kernel /boot/vmlinuz-version ro root=/dev/sda5
    #          initrd /boot/initrd-[generic-]version.img
    #boot=/dev/sda
    default=0
    timeout=5
    splashimage=(hd0,4)/boot/grub/splash.xpm.gz
    hiddenmenu
    title CentOS-server (3.6.0)
        root (hd0,4)
        kernel /boot/vmlinuz-3.6.0 ro root=UUID=437322a2-0c0d-42b6-8e61-ed028f329fd1 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-3.6.0.img
    title CentOS-server (2.6.32-279.el6.x86_64)
        root (hd0,4)
        kernel /boot/vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=437322a2-0c0d-42b6-8e61-ed028f329fd1 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-279.el6.x86_64.img
    title CentOS-server-2 (2.6.32-279.el6.x86_64)
        root (hd0,6)if
        kernel /boot/vmlinuz-2.6.32-279.el6.x86_64 ro root=UUID=51e0c6ab-00d8-40d8-bc14-299431638cf2 rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-279.el6.x86_64.img
    title Win7
        rootnoverify (hd0,0)
        chainloader +1

    注:

    • 如果之前有CentOS,再装一个,后一个的grub会代替前者,没有开机选单而直接进入新装的系统中,因此更快捷的修复办法是单击【位置】——>【之前存在的文件系统】来挂载——>【gedit /etc/grub.conf】就能找到之前系统的引导配置,将相关内容拷贝到现在系统的/etc/grub.conf里即可。
    • title可以随便改,体现的是开机选单上的名字。
    • 注释掉hiddenmenu,开机选单就能出现。
    • 想让哪个系统默认启动,就把它放在/etc/grub.conf的第一个,比如hiddenmenu之后。

    【参考资料】

    重装windows后修复CentOS的Grub http://papmp.blog.163.com/blog/static/131716223201002943851594/

  • 相关阅读:
    开通了
    A computer hardware platform abstraction
    脑机接口入门概览
    JDK自带VM分析工具jps,jstat,jmap,jconsole
    泛型里的super和extend
    动态规划
    用二分法查找的套路(一)
    A computer hardware platform abstraction
    CentOS7安装JDK1.8
    CentOS7如何修改hostname
  • 原文地址:https://www.cnblogs.com/qyddbear/p/2746297.html
Copyright © 2020-2023  润新知