今天没事安装了一个CENTOS和ubuntu,先安装的centos后安装的ubuntu,安装完ubuntu后发现grub启动菜单里没有 centos的选项,后在google.com中查到了如果利用centos来引导ubuntu的方法,把我操作的过程记录下来,方便以后查找.
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/
centos ubuntu 双系统引导的grub设置
最新推荐文章于 2024-06-08 12:44:51 发布