电脑安装Windows7+Ubuntu+Centos三系统的配置方法

首先用用U盘制作centos7的启动盘,具体方法请百度,在此不再累述。这里需要注意的是制作好的启动盘是不需要删除包,也不需要拷贝镜像文件,刻录完就可以直接使用了,但是在安装的时候,需要修改U盘的位置:

在用u盘安装过程中,在进入安装界面,按tab键修改或者直接按e键

将vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet 改为:

vmlinuz initrd=initrd.img inst.stage2=hd:/dev/sdb4 quiet

其中hd:/dev/sdb4代表U盘的位置,不同电脑的位置可能不一样,认准自己U盘的位置就好了。

安装第三个系统centos7后会碰到在开机时windows7没有引导的问题,解决方法是使用centos系统作为引导系统。方法如下:

修改/boot/grub2/grub.cfg这个文件,向这个文件添加引导windows的脚本

menuentry'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-xxx'{
insmod chain
insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
chainloader +1
}

还有另一种解决方法,但是笔者没有成功,写出来大家参考一下:

步骤:

1、切换到root权限

su

2、执行命令

grub2-mkconfig -o /boot/grub2/grub.cfg

执行详情如下
[[email protected] jiezh]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.4.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.4.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-70ff68ea7ac34677a25f45f3417dd76c
Found initrd image: /boot/initramfs-0-rescue-70ff68ea7ac34677a25f45f3417dd76c.img
Found Windows 7 (loader) on /dev/sdb1
done

修改完成后保存并重启电脑,开机重启就可以看到windows7的引导了。

如果是Ubuntu上引导,可以做#sudo update-grub2也可以实现上述windows7的引导,添加代码比较复杂,如下:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -s $prefix/grubenv ]; then
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-8091b91e-1049-4c97-8e64-59fa7cda6671' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos10'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos10 --hint-efi=hd0,msdos10 --hint-baremetal=ahci0,msdos10 --hint='hd0,msdos10' ab21651b-b9d9-403a-9115-f288ca6b7bd5
else
search --no-floppy --fs-uuid --set=root ab21651b-b9d9-403a-9115-f288ca6b7bd5
fi
linux16 /vmlinuz-3.10.0-123.el7.x86_64 root=UUID=8091b91e-1049-4c97-8e64-59fa7cda6671 ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet LANG=zh_CN.UTF-8
initrd16 /initramfs-3.10.0-123.el7.x86_64.img
}

menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $menuentry_id_option 'osprober-chain-xxx'{
insmod chain
insmod part_msdos
insmod ntfs
set root='hd0,msdos1'
chainloader +1
}

menuentry 'CentOS Linux, with Linux 0-rescue-a9741edb99374138ad3514311cc1ba77' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-a9741edb99374138ad3514311cc1ba77-advanced-8091b91e-1049-4c97-8e64-59fa7cda6671' {
load_video
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos10'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos10 --hint-efi=hd0,msdos10 --hint-baremetal=ahci0,msdos10 --hint='hd0,msdos10' ab21651b-b9d9-403a-9115-f288ca6b7bd5
else
search --no-floppy --fs-uuid --set=root ab21651b-b9d9-403a-9115-f288ca6b7bd5
fi
linux16 /vmlinuz-0-rescue-a9741edb99374138ad3514311cc1ba77 root=UUID=8091b91e-1049-4c97-8e64-59fa7cda6671 ro rd.lvm.lv=centos/swap vconsole.font=latarcyrheb-sun16 rd.lvm.lv=centos/root crashkernel=auto vconsole.keymap=us rhgb quiet
initrd16 /initramfs-0-rescue-a9741edb99374138ad3514311cc1ba77.img
}
if [ "x$default" = 'CentOS Linux, with Linux 3.10.0-123.el7.x86_64' ]; then default='Advanced options for CentOS Linux>CentOS Linux, with Linux 3.10.0-123.el7.x86_64'; fi;
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Ubuntu 13.04 (13.04) (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-0cbece5c-328e-4f94-aa52-da220cca34a2' {
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9' 0cbece5c-328e-4f94-aa52-da220cca34a2
else
search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
fi
linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro locale=zh_CN quiet splash $vt_handoff
initrd /boot/initrd.img-3.8.0-19-generic
}
submenu 'Advanced options for Ubuntu 13.04 (13.04) (on /dev/sda9)' $menuentry_id_option 'osprober-gnulinux-advanced-0cbece5c-328e-4f94-aa52-da220cca34a2' {
menuentry 'Ubuntu (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.8.0-19-generic--0cbece5c-328e-4f94-aa52-da220cca34a2' {
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9' 0cbece5c-328e-4f94-aa52-da220cca34a2
else
search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
fi
linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro locale=zh_CN quiet splash $vt_handoff
initrd /boot/initrd.img-3.8.0-19-generic
}
menuentry 'Ubuntu,Linux 3.8.0-19-generic (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.8.0-19-generic--0cbece5c-328e-4f94-aa52-da220cca34a2' {
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9' 0cbece5c-328e-4f94-aa52-da220cca34a2
else
search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
fi
linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro locale=zh_CN quiet splash $vt_handoff
initrd /boot/initrd.img-3.8.0-19-generic
}
menuentry 'Ubuntu,Linux 3.8.0-19-generic (恢复模式) (on /dev/sda9)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-3.8.0-19-generic--0cbece5c-328e-4f94-aa52-da220cca34a2' {
insmod part_msdos
insmod ext2
set root='hd0,msdos9'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos9 --hint-efi=hd0,msdos9 --hint-baremetal=ahci0,msdos9 --hint='hd0,msdos9' 0cbece5c-328e-4f94-aa52-da220cca34a2
else
search --no-floppy --fs-uuid --set=root 0cbece5c-328e-4f94-aa52-da220cca34a2
fi
linux /boot/vmlinuz-3.8.0-19-generic root=UUID=0cbece5c-328e-4f94-aa52-da220cca34a2 ro recovery nomodeset locale=zh_CN
initrd /boot/initrd.img-3.8.0-19-generic
}
}

### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

 


标签:  |  | 


顶部