Booting Linux from Windows' Boot Manager

By Thiravudh Khoman

Some people aren't aware of this, but it's possible to use Windows NT/2000's boot manager to boot into Linux (besides booting Windows of course). In a nutshell, what you need to do is to: a) save the first 512 bytes of the Linux boot partition to a file, b) copy that file to C:/, and then c) add a line to C:/BOOT.INI that points to that file.
There are several reasons why you might want to do this: a) you may be more comfortable with Windows' boot manager, b) if you decide to remove Linux from your system one day, you'll still have the Windows boot manager around, rather than being left with LILO or GRUB, c) you can boot into a Linux installation that's located above 1024 cylinders without using a boot diskette (granted, many Linux boot managers can do this now too.)
Assumptions
Before we proceed, let's make a few assumptions:
  • You're using a single hard disk that already has Windows 2000 Professional and/or Windows 2000 Server (or Windows NT for that matter) installed on it. Presumably, this should work on a system with two or more hard disks as well.
  • You have sufficient free space on the hard disk on which to install Linux. If not, you'll need to do some re-partitioning or add another hard disk.
  • You're going to install Red Hat Linux v8.0 (hereafter, "RH8"). Actually, this procedure should work with most any Linux distribution, although the sections I'm flagging will probably be located or labeled differently.
  • You have 2 diskettes ready. The first one will be overwritten completely to create a Linux boot diskette, so make sure nothing is needed on it. The second one should be DOS formatted and need not be empty since we will only need enough space to save a 512 byte file.
Step by Step
Here are the exact steps:
  1. Back up your data if you care to do so (i.e. don't blame me if this doesn't work or screws things up).
  2. Place the first RH8 CD into your CD-ROM drive and boot your computer from it.
  3. Run through the RH8 installation process as per your book or instructor until you come to the screen that's titled: "Boot Loader Configuration" (figure 1 - This is a sample screen only!).
  4. On this screen, check the "Configure advanced boot loader options" box and then click "Next".
  5. On the next screen ("Advanced Boot Loader Configuration") (figure 2 - This is a sample screen only!), under the "Install Boot Loader Record on" section, make the sure the radio button next to "/dev/hda# First sector of boot partition" is selected. On my computer, hda# is hda5. On your system, it may be different. Write down this hda number because you will need it later!
WARNING: It is critical that you DO NOT install the Linux boot loader into the Master Boot Record (MBR) as this will overwrite the Windows boot manager! Be VERY, VERY careful here!
  1. Click "Next" and continue with the installation process until you come to the "Boot Disk Creation" screen (figure 3).
  2. Make sure the radio button next to "Yes, I would like to create a boot disk" is selected (it is, by default) and then click "Next".
  3. Proceed with the boot disk creation and remove it when it is finished.
  4. Continue with the installation process as instructed. Before re-booting at the end of the installation, remove the second RH8 CD and insert the Linux boot diskette you created. You will next boot Linux with this diskette.
  5. The first time RH8 loads, you will be prompted to perform a few additional post-installation tasks. Do or don't do these as you wish.
  6. When you finally reach the Linux login screen, login as root.
  7. Open up a terminal window (System Tools -> Terminal).
  8. You will now need the hda number you wrote down. Assuming that the boot partition is at hda5, type:
dd if=/dev/hda5 of=boot.lnx bs=512 count=1
If hda5 is NOT your boot partition, change it as appropriate. If you FORGOT what your hda number was, from the terminal window, type: df, then determine which hda# is associated with the /boot partition.
  1. A file named "boot.lnx" should now have been created in root's home directory. Do an "ls -l boot.lnx" to confirm this.
  2. Insert a DOS formatted floppy diskette into the floppy drive and while still in the terminal window, type:
mcopy boot.lnx a:
This uses MTOOL's "mcopy" command to copy a file from a Linux partition to a DOS formatted diskette.
  1. Remove the DOS diskette.
  2. While still in the terminal window, type:
shutdown -r now
This will reboot your computer.
  1. With no CD in the CD drive or floppy in the floppy drive, your computer should still boot into Windows. If you have more than one copy of Windows installed, the Windows boot manager selection screen should appear. It really doesn't matter which Windows you boot into, but it makes sense to boot into the fastest loading Windows.
  2. Make sure you log into Windows as administrator or as an adminstrator-equivalent. Once you're inside Windows, go to the command prompt (Start -> Accessories -> Command Prompt). If you're not already there, change to the root of the C: drive.
  3. Insert the DOS floppy diskette that contains the boot.lnx file into the floppy drive and then copy it to C:/ using the DOS copy command or Windows Explorer.
  4. Next, we need to edit the BOOT.INI file so that it knows about boot.lnx. BOOT.INI should be a system file and hidden from view. When you type:
attrib boot.ini
the attributes of BOOT.INI should be A (archive), S (system), and H (hidden).
  1. In order to edit BOOT.INI, you will need to change its attributes first. Type:
attrib -s -h boot.ini
  1. Now that BOOT.INI has been unprotected, you can either edit it from DOS with EDIT.COM or from Windows with NOTEPAD. If you choose the latter, leave the command prompt window open for the time being since you will need to change BOOT.INI's attributes back to SH later.
  2. Inside the editor of your choice, add a line to the end of the file that contains the following:
c:/boot.lnx="Red Hat Linux v8.0"
The text between the double quotes are comments and you can change it as you see fit.
  1. Depending on how many copies of Windows you have installed, your BOOT.INI may now look SOMETHING like this:
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)/WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)/WINNT="Microsoft Windows 2000 Professional" /fastdetect
c:/boot.lnx="Red Hat Linux v8.0"
  1. Save the changes you made to BOOT.INI and then return to the command prompt and type:
attrib +s +h boot.ini
  1. If you wish to change the order of the selections in the boot manager screen (e.g. to make Linux appear before Windows), just change the order of the relevant lines in BOOT.INI. Likewise, if you wish Linux to be the default selection, change the text after the "default=" line to:
default=c:/boot.lnx
  1. Reboot your computer and the Windows boot manager should now provide the added option to boot into Linux. Select "Linux" and notice that you will be taken to the Linux boot manager (probably GRUB) screen first. Finally, within GRUB, select "Red Hat Linux (2.4.xx-xx)" and Linux will start its regular boot process. (Interesting trivia: Selecting "DOS" will take you back to Windows' boot manager screen).
  2. At this point in time, you will no longer need either of the floppy diskettes. But as with all boot/rescue diskettes, it might be wise to save the Linux boot disk if you can spare it.
Sources
I learned about this technique from an excellent book by Mike McCune titled "Integrating Linux and Windows" (Open Source Technology Series, Prentice Hall PTR, 2001, 392 pp, List Price: $39.99).
If you plan to straddle both the Windows and the Linux worlds, I'd highly recommend this book. Although it's not exactly a book for beginners, it illustrates how a variety of tasks can be performed under both Windows and Linux, and how the two may be made to co-exist. It's about two years old though, and could certainly do with a wee update.
 
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值