Win7下安装双系统Centos,并修复Centos引导加载程序安装在U盘上的问题

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

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

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

3、Centos修复grub启动加载程序

  参考并转自:http://blog.csdn.net/llhwin2010/article/details/8435153


用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) [ 以我的系统为例,我的Centos系统中目录/boot的分区号为6,所以此处该为root (hd0,6) ]
  2. Filesystem type is ext2fs, partition type 0x83
  3. grub> setup (hd0)
  4. Checking if "/boot/grub/stage1" exists... no
  5. Checking if "/grub/stage1" exists... yes
  6. Checking if "/grub/stage2" exists... yes
  7. Checking if "/grub/e2fs_stage1_5" exists... yes
  8. Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
  9. succeeded
  10. Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
  11. Done.
  12. grub> reboot

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

Linux代码

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

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

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

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

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

3、Centos修复grub启动加载程序

  参考并转自:http://blog.csdn.net/llhwin2010/article/details/8435153


用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) [ 以我的系统为例,我的Centos系统中目录/boot的分区号为6,所以此处该为root (hd0,6) ]
  2. Filesystem type is ext2fs, partition type 0x83
  3. grub> setup (hd0)
  4. Checking if "/boot/grub/stage1" exists... no
  5. Checking if "/grub/stage1" exists... yes
  6. Checking if "/grub/stage2" exists... yes
  7. Checking if "/grub/e2fs_stage1_5" exists... yes
  8. Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
  9. succeeded
  10. Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
  11. Done.
  12. grub> reboot

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

Linux代码

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

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