1、使用U盘安装Centos时,磁盘分区划分要注意:系统(包含Win7)只能4个主分区,所以只能在删除一个主分区或者在扩展分区的空闲分区内建立目录。

2、Centos在安装步骤的最后,引导加载程序的选项只有“安装在U盘”一项,注:不可轻易选择安装在MBR上,会覆盖掉Win7系统的引导加载程序。

  所以我们先选择将引导加载程序安装在U盘上,然后再修复。

3、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. (hd0,6)


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

[因为正常情况下,我们的电脑里只有一块硬盘,所以第二个硬盘是指U盘。(hd1 -->  hd0 )至于分区,在使用空闲磁盘空间创建目录时,会显示设备名如/dev/sda'x',所在分区即为‘x-1',或者使用df命令查看/boot目录的所在磁盘]

 

下面进入正题

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



Linux代码



    1. grub> root (hd0,6)    
    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 (hd0,6)  [与上面/boot分区号对应]   
    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,6)   /grub/splash.xpm.gz      
    15. hiddenmenu     
    16. title CentOS (2.6.18-274.3.1.el5)      
    17. root (hd0,6) 
    18. 2.6.18-274.3.1.el5 ro root=/dev/VolGroup00/LogVol00      
    19. 2.6.18-274.3.1.el5.img      
    20. title CentOS (2.6.18-238.el5)      
    21.  root (hd0,6)   
    22. 2.6.18-238.el5 ro root=/dev/VolGroup00/LogVol00      
    23. 2.6.18-238.el5.img      
    24. title Other     
    25.  rootnoverify (hd0,6)    
    26. 1

     



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