CentOS Ubuntu 双系统引导的grub设置

1,先安装CentOS,再安装Ubuntu.
2,用CentOS安装盘启动,在出现启动选项的时候用linux rescue
在shell下执行
chroot /mnt/sysimage
grub-install /dev/sda
修复CentOS的grub,然后reboot
3.进入CentOS
挂接Ubuntu的分区
mount /dev/sda6 /media
vi /media/boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
have_grubenv=true
load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
saved_entry=${prev_saved_entry}
save_env saved_entry
prev_saved_entry=
save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set 1a2b230e-d172-4b48-8395-72a33ebce462
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=640x480
insmod gfxterm
insmod vbe
if terminal_output gfxterm ; then true ; else
# For backward compatibility with versions of terminal.mod that don't
# understand terminal_output
terminal gfxterm
fi
fi
if [ ${recordfail} = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
set quiet=1
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set 1a2b230e-d172-4b48-8395-72a33ebce462
linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro   quiet splash
initrd  /boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
recordfail=1
if [ -n ${have_grubenv} ]; then save_env recordfail; fi
insmod ext2
set root=(hd0,2)
search --no-floppy --fs-uuid --set 1a2b230e-d172-4b48-8395-72a33ebce462
linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro single
initrd  /boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###    

复制下面内容并带上uuid
linux   /boot/vmlinuz-2.6.31-14-generic root=UUID=1a2b230e-d172-4b48-8395-72a33ebce462 ro   quiet splash
initrd  /boot/initrd.img-2.6.31-14-generic
编辑CentOS的grub.conf,把复制的内容加入到grub.conf中,并修改如下所示
vi /boot/grub/grub.conf
title Ubuntu 9.10
root (hd0,0)
kernel   /vmlinuz-2.6.31-14-generic root=UUID=b2a79ba9-abbc-45dd-810d-2052cd782aea ro   quiet splash
initrd  /initrd.img-2.6.31-14-generic

cp Ubuntu 下的vmlinuz 及initrd到CentOS的boot下面
cp /media/boot/vmlinuz-2.6.31-14-generic /boot/
cp /media/boot/initrd.img-2.6.31-14-generic /boot/

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/26869.html