`

CentOS修改grub启动引导

 
阅读更多

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

 

进入grub

Linux代码  收藏代码
  1. [root@mfsmaster home]# /sbin/grub  

 

找到grub的位置

Linux代码  收藏代码
  1. grub> find /grub/stage1     
  2.  (hd1,0)    

 

 如果提示Error 15: File not found,则尝试 find /boot/grub/stage1 或者 find stage1 
(hd1,0)代表的第二个硬盘的第一个分区,相应的(hd0,0)代表的就是第一个硬盘第一个分区,这一步其实就是告诉我们引导被写入了U盘中= =

 

下面进入正题

我们将引导写入(hd0,0),即第一个磁盘第一个分区中,我在这里的系统盘是这个,具体可以在linux下用df指令查看

Linux代码  收藏代码
  1. grub> root (hd0,0)     
  2.  Filesystem type is ext2fs, partition type 0x83    
  3.     
  4. grub> setup (hd0)     
  5.  Checking if "/boot/grub/stage1" exists... no     
  6.  Checking if "/grub/stage1" exists... yes     
  7.  Checking if "/grub/stage2" exists... yes     
  8.  Checking if "/grub/e2fs_stage1_5" exists... yes     
  9.  Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.     
  10. succeeded     
  11.  Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded     
  12. Done.     
  13.     
  14. grub> reboot    

 

然后修改启动的 /boot/grub/menu.lst 或者 /boot/grub/grub.conf  CentOS下这两个文件是绑定的,改一个即可

Linux代码  收藏代码
  1. [root@mfsmaster home]# vi /boot/grub/menu.lst     
  2.     
  3. # grub.conf generated by anaconda     
  4. #     
  5. # Note that you do not have to rerun grub after making changes to this file     
  6. # NOTICE:  You have a /boot partition.  This means that     
  7. #          all kernel and initrd paths are relative to /boot/, eg.     
  8. #          root (hd1,0)     
  9. #          kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00     
  10. #          initrd /initrd-version.img     
  11. #boot=/dev/sdb     
  12. default=0    
  13. timeout=5    
  14. splashimage=(hd0,0)/grub/splash.xpm.gz     
  15. hiddenmenu     
  16. title CentOS (2.6.18-274.3.1.el5)     
  17.         root (hd0,0)     
  18.         kernel /vmlinuz-2.6.18-274.3.1.el5 ro root=/dev/VolGroup00/LogVol00     
  19.         initrd /initrd-2.6.18-274.3.1.el5.img     
  20. title CentOS (2.6.18-238.el5)     
  21.         root (hd0,0)     
  22.         kernel /vmlinuz-2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00     
  23.         initrd /initrd-2.6.18-238.el5.img     
  24. title Other     
  25.         rootnoverify (hd0,3)     
  26.         chainloader +1    

 

把当中的(hd1,0)都改成(hd0,0),splashimage=(hd0,0)/grub/splash.xpm.gz 这个是开机引导背景图片的位置,改不改都关系不大,重启CentOS就可以正常启动了

近期经常出现centos 到启动窗口之后 又重新启动问题,是由于centos启动超时,设置timeout=20,加大超时时间

 参考文档:http://liyiting.iteye.com/blog/1206930

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics