虚拟化容器,大数据,DBA,中间件,监控。

如何用linux菜单启动另一硬盘中的windows

17 11月
作者:admin|分类:系统运维
  如何用linux菜单启动另一硬盘中的windows


我有两块硬盘,一个装linux,一个装windws,我每次都要在BIOS改启动顺序,才可以启动XP。这样太麻烦了。用开机菜单选项。可以更改/boot/grub/grub.conf

1。从第一硬盘第一分区启动(这个一般不用改)
rootnoverify (hd0,0)
makeactive
chainloader +1

2。从第二硬盘第一分区启动
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
makeactive
chainloader +1


用以交换启动硬盘顺序的,去掉了就不行的
看看这两篇文章:[www.gnu.org]
[www.gnu.org]

一是:
Command: map to_drive from_drive

    Map the drive from_drive to the drive to_drive. This is necessary when you chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive. Here is an example:

              grub> map (hd0) (hd1)
              grub> map (hd1) (hd0)
        

    The example exchanges the order between the first hard disk and the second hard disk. See also DOS/Windows


二是:4.2.6 DOS/Windows

GRUB cannot boot DOS or Windows directly, so you must chain-load them (see Chain-loading). However, their boot loaders have some critical deficiencies, so it may not work to just chain-load them. To overcome the problems, GRUB provides you with two helper functions.

If you have installed DOS (or Windows) on a non-first hard disk, you have to use the disk swapping technique, because that OS cannot boot from any disks but the first one. The workaround used in GRUB is the command map (see map), like this:

     grub> map (hd0) (hd1)
     grub> map (hd1) (hd0)

This performs a virtual swap between your first and second hard drive.

Caution: This is effective only if DOS (or Windows) uses BIOS to access the swapped disks. If that OS uses a special driver for the disks, this probably won't work.

Another problem arises if you installed more than one set of DOS/Windows onto one disk, because they could be confused if there are more than one primary partitions for DOS/Windows. Certainly you should avoid doing this, but there is a solution if you do want to do so. Use the partition hiding/unhiding technique.

If GRUB hides a DOS (or Windows) partition (see hide), DOS (or Windows) will ignore the partition. If GRUB unhides a DOS (or Windows) partition (see unhide), DOS (or Windows) will detect the partition. Thus, if you have installed DOS (or Windows) on the first and the second partition of the first hard disk, and you want to boot the copy on the first partition, do the following:

     grub> unhide (hd0,0)
     grub> hide (hd0,1)
     grub> rootnoverify (hd0,0)
     grub> chainloader +1
     grub> makeactive
     grub> boot





我有两个硬盘,硬盘hda(即hd0)装的是Linux系统,硬盘hdb(即hd1)装的是Windows系统。

打开/boot/grub/grub.conf

在文件后面加上下面的语句:

title Windows 2003
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1
makeactive
boot

这样就可以实现了

注意:命令与参数之间的空格;还有,上面的“chainloader +1”中,“chainloader”与“+1”

之间有空格,但“+1”的“+”和“1”之间是没有空格的。

我是菜鸟,为这个试了N次才弄明白。

至于Windows系统是FAT格式还是NTFS格式无关紧要,GRUB都能支持。

我的grub.conf全文如下:

#------------------------------------------------------------------------------
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hda2
#          initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-8)
root (hd0,0)
kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
initrd /initrd-2.4.20-8.img
title Windows 2003
map (hd0) (hd1)
map (hd1) (hd0)
rootnoverify (hd1,0)
chainloader +1
makeactive
boot
#------------------------------------------------------------------------------

注意各参数中间的空格:map空格(hd0)空格(hd1)
如是是两个系统都装在一个硬盘上,那就不需要用“map”这两行了,改成如下即可:

title   windows 2003
root (hd0,4)
chainloader +1
makeactive
boot

# 或将“root (hd0,4)”改成“rootnoverify (hd0,4)”也是可以的
# 这里假设Windows系统装在第五个分区

附注:有一点我还不明白,就是接第二块硬盘时,我把它设成第一个IDE接口的从盘或直接接在

第二个IDE接口,按Linux里的说明,接在IDE1上做从盘时,硬盘的标识是hdb,接在IDE2上时,

硬盘的标识是hdc(做主盘)或hdd(做从盘),对应的代号应该是hd1,hd2,hd3。但在grub.conf

文件中,与接在哪个接口好像没关系。我接在不同的位置,无须修改grub.conf文件,都可以启动

到Windows。希望高手指点。



我如何修改GRUB实现将安装在另外一个硬盘的windows加入多系统引导中?
解决方法:

本文假设以下前提: 1. GRUB是系统的默认引导程序; 2. RHEL安装在/dev/hda或者其他基本主设备(例如/dev/sda)。 3. windows安装在/dev/hdb或者其他基本辅设备上(例如/dev/sdb)。

一旦成功的安装了windows和linux,下一步就需要修改GRUB引导程序,实现启动时可选择进入不同的操作系统。首先确保机器启动时,默认是启动进入linux,这表明BIOS中是从主基本设备上启动的。

启动进入linux,并以root登录,然后打开编辑器编辑/etc/grub.conf,将会看到类似以下的内容:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hda7
#          initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=7
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.4.21-20.EL)
        root (hd0,0)
        kernel /vmlinuz-2.4.21-20.EL ro root=LABEL=/
        initrd /initrd-2.4.21-20.EL.img

修改文件添加以下内容:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/hda7
#          initrd /initrd-version.img
#boot=/dev/hda
default=1
timeout=7
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux AS (2.4.21-20.EL)
        root (hd0,0)
        kernel /vmlinuz-2.4.21-20.EL ro root=LABEL=/
        initrd /initrd-2.4.21-20.EL.img
title Windows XP
        root (hd1,0)
        map (hd1) (hd0)
        map (hd0) (hd1)
        makeactive.
        chainloader +1

"title Windows XP"指示GRUB显示的选项内容,重新起动机器以后,在GRUB将会多一个选项:Windows XP。

"root (hd1,0)"表示该操作系统安装在哪个硬盘的哪个分区,本示例中windows安装在/dev/hdb上。

后面两行"map (hd1) (hd0)"和"map (hd0) (hd1)"使用磁盘互换技术,因为 OS只能从第一个硬盘启动,这两条指令实现把两个硬盘进行虚拟互换。

最后两行设置活动标志,,并指示GRUB从哪里启动。

浏览2391 评论0
返回
目录
返回
首页
电信送的上海贝尔无线路由猫 超级帐号与密码 永中集成Office 2009 for windows/Linux的注册方法