当前位置:操作系统 > Unix/Linux >>

centos用u盘安装修复启动项的方法

 CentOS修改grub启动引导
用U盘安装CentOS,如果使用默认的boot挂载,会将引导安装在U盘上,必须用U盘启动,遇到这种情况可以通过grub手动写入引导。(我在另一台服务器上安装时手动设置boot但是装好停留在Grub无法启动,这个没深入研究了,在这里就先说手动修改引导方法,给遇到同样问题的人参考,如有错误,欢迎拍砖)
进入grub

[root@mfsmaster home]# /sbin/grub 
找到grub的位置
Linux代码  复制代码  收藏代码
grub> find /grub/stage1     
(hd1,0)   
如果提示Error 15: File not found,则尝试 find /boot/grub/stage1 或者 find stage1 
(hd1,0)代表的第二个硬盘的第一个分区,相应的(hd0,0)代表的就是第一个硬盘第一个分区,这一步其实就是告诉我们引导被写入了U盘中= =
下面进入正题
我们将引导写入(hd0,0),即第一个磁盘第一个分区中,我在这里的系统盘是这个,具体可以在linux下用df指令查看
Linux代码  复制代码  收藏代码
grub> root (hd0,0)     
Filesystem type is ext2fs, partition type 0x83    
    
grub> setup (hd0)     
Checking if "/boot/grub/stage1" exists... no     
Checking if "/grub/stage1" exists... yes     
Checking if "/grub/stage2" exists... yes     
Checking if "/grub/e2fs_stage1_5" exists... yes     
Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.     
succeeded     
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded     
Done.     
    
grub> reboot   
然后修改启动的 /boot/grub/menu.lst 或者 /boot/grub/grub.conf  CentOS下这两个文件是绑定的,改一个即可
Linux代码  复制代码  收藏代码
[root@mfsmaster home]# vi /boot/grub/menu.lst     
    
# grub.conf generated by anaconda     
#     
# Note that you do not have to rerun grub after making changes to this file     
# NOTICE:  You have a /boot partition.  This means that     
#          all kernel and initrd paths are relative to /boot/, eg.     
#          root (hd1,0)     
#          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00     
#          initrd /initrd-version.img     
#boot=/dev/sdb     
default=0    
timeout=5    
splashimage=(hd0,0)/grub/splash.xpm.gz     
hiddenmenu     
title CentOS (2.6.18-274.3.1.el5)     
        root (hd0,0)     
        kernel /vmlinuz-2.6.18-274.3.1.el5 ro root=/dev/VolGroup00/LogVol00     
        initrd /initrd-2.6.18-274.3.1.el5.img     
title CentOS (2.6.18-238.el5)     
        root (hd0,0)     
        kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00     
        initrd /initrd-2.6.18-238.el5.img     
title Other     
        rootnoverify (hd0,3)     
        chainloader +1   
把当中的(hd1,0)都改成(hd0,0),splashimage=(hd0,0)/grub/splash.xpm.gz 这个是开机引导背景图片的位置,改不改都关系不大,重启CentOS就可以正常启动了
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,