首页 > Windows开发 > 详细

Use grub to load PC-BSD and Windows XP

时间:2014-04-04 12:05:32      阅读:660      评论:0      收藏:0      [点我收藏+]

This is a common question about booting PC-BSD and other OS, usually Windows.

I would like to share my configuration with grub.

First, I think you shall read the manual by GNU. It‘s very comprehensible.

My situation is PC-BSD on one hard disk and Windows XP on another hard disk.

The BIOS sets up the hard disk carrying PC-BSD has boot priority. But the hard disk with Windows XP is with lower IDE index.

So, I will use the grub on PC-BSD to boot Windows XP as well.

The grub is automatically installed and started after installation of PC-BSD.

The entries for PC-BSD is automatically configured as well.

So, I just need to add some custom config in the /boot/grub/custom.cfg

grub, in fact, reads /boot/grub/grub.cfg only, but you shall not update this file in most cases. The contents in custom.cfg is executed in grub.cfg in fact.

bubuko.com,布布扣
1 ### BEGIN /usr/local/etc/grub.d/41_custom ###
2 if [ -f  ${config_directory}/custom.cfg ]; then
3   source ${config_directory}/custom.cfg
4 elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
5   source $prefix/custom.cfg;
6 fi
7 ### END /usr/local/etc/grub.d/41_custom ###
bubuko.com,布布扣

In the custom.cfg, I added the following lines only.

bubuko.com,布布扣
1 # Start Windows XP Submenu
2 submenu "Windows XP" {
3   #insmod chain
4   insmod ntfs
5   set root=(hd0,1)
6   chainloader +1
7   exit
8 }
bubuko.com,布布扣

Lines starting with "#" are comments.

The line #2 is to add a sub-menu, which will be line with sub-menu for PC-BSD.

The insmod command is to load grub modules. According to the manual, chain and ntfs shall be loaded. But I found Windows can not boot if I loaded chain. I did not why. So, I simply comment it out.

Since my Windows is on the lower hard disk, the first partition, (hd0,1) is set as root for Windows.

The line #6 is the key for Windows booting. Because grub cannot boot Windows directly, chainloader means to request boot loader of Windows to boot itself.

The line #7 is not found in manual. But I found it‘s necessary to boot the Windows. I found it during interactive trials.

So, that‘s all you need to configure for grub to load PC-BSD plus Windows XP. It shall be also appliable for grub configuration on other OS, e.g. Linux.

Use grub to load PC-BSD and Windows XP,布布扣,bubuko.com

Use grub to load PC-BSD and Windows XP

原文:http://www.cnblogs.com/jieyuan-shen/p/3643880.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!