Tuesday, February 09, 2010  
Google
Web pcquest.com

CIOL Network sites

Search by Issue | Sitemap | Advanced Search

• For most updated version of DQ TOP 20 issue, visit dqindia.com • Visit the New Living Digital 2.0

------------------------------------------------------------
This story was printed from PCQuest at http://www.pcquest.com/
------------------------------------------------------------

Article Title: Booting Linux with the Win 2k Boot Loader
URL: http://www.pcquest.com/content/search/showarticle1.asp?arid=15488
Section: Network
Author Name: Vinod Unny
Author Email: vinod@isquaretech.com
------------------------------------------------------------

Booting up a PC is a complex process. When a PC starts up, instructions in the BIOS make it look at the first sector (Sector #0) of the primary hard disk, assuming that the primary hard disk is the first boot device, and loads the data residing there into memory. The data consists of the partition table and the Master Boot Record (MBR). The MBR contains a small, but important program called the Master Boot Code (MBC). This contains instructions on where to find the rest of the operating system—that is, the location of the rest of the OS on the physical hard disk. This address is nothing but the partition on which the rest of the operating system kernel resides. Once the MBC points to the correct location, the BIOS starts executing the code for the OS from there.

Every operating system has its own MBC. The code can be a simple set of instructions that point to one particular location, like in DOS or Win 9x; or a more interactive one that presents a menu of selections or allows you to type in a command, like the ones in Win NT/2000 and Linux. Every time you install a new operating system, it overwrites the current MBR with its own MBC that points to the new OS.

If you’ve installed Linux while retaining an existing Windows installation, you know you can switch between the Windows and Linux OSs by typing in the correct label at the LILO: prompt. For example, if your Windows installation was named "dos" (which it is by default), type in "dos" at the LILO: prompt and you can boot into Windows without any problem. This is nothing but the Linux boot loader at work.

However, for those of you who’ve used Win NT/2000, you have a different boot loader. NT shows a menu of currently installed operating systems and lets you switch between them by using the arrow keys and pressing "Enter" on the highlighted choice. Win 2000 doesn’t show you a list of choices by default, although you have the option to see if you wish.

If you’re only an occasional user of Linux, playing around and experimenting during your free time, but use NT/2000 much more often, you’d like to have Linux on the NT boot menu rather than the other way around. Unfortunately, this doesn’t recognize the Linux boot partition at all. So we’ll have to do some tweaking to get this to work.

This article will show you how to get Linux as an option in the Win 2000 boot menu under three different configurations—when Win 2000 is already installed and you want to install Linux, when Linux is already installed and you want to install Win 2000, and finally when both are installed and LILO is the boot loader. Most of these instructions should work with NT 4 too, but haven’t been tested with it.

Windows 2000 installed

This is the configuration that might be most common. Here, I assume you have enough unpartitioned space left on the drive to install Red Hat Linux 6.2 given on the PC Quest June 2000 CD, and that you know how to install Linux as well as Windows 2000.

First, create an Emergency Boot Disk for your Win 2000 installation by going to Start>Programs>Accessories>System Tools>Backup and clicking the Emergency Repair Disk. Insert a new, blank floppy when prompted. You should always do this.

Now boot off the PCQ Red Hat 6.2 CD and start the install process as usual. When you reach Disk Druid, don’t touch the Win 2000 partition(s). Simply add as many partitions as you want for the Linux install on the remaining free space. Continue till the point where you’re asked where to install LILO, the Linux boot loader.

The next two steps are very important. Don’t choose the Master Boot Record in this step; instead choose the first sector of the root partition. And when prompted to create a Boot Disk, do so. I can’t stress this point enough. Create the Boot Disk right now, or you may not be able to access your Linux installation without reinstalling it.

Once the Linux installation is complete, let the system reboot. If you’ve followed the instructions correctly, you should be booting into Win 2000 as usual, as if there were no Linux around. Put in the Linux boot floppy and reboot. This will show you the LILO prompt. Press "Enter" and get into your Linux installation.

Now take a look at /etc/lilo.conf. This is the boot configuration file that contains the name of the partition that holds the boot information. Look for a line that says: boot=/dev/hdxy. This line informs the OS loader which device to use for booting up. The "hd" stands for hard disk, the "x" is the physical device on your system and the "y" is the partition number on that physical device. So, if your Linux boot partition was on the third partition of your first hard disk, your boot device would be /dev/hda3. If it were on the second partition of the second physical hard disk, it would be /dev/hdb2.

After you make a note of the correct device, su as root and issue the following command:

dd if=/dev/hdxy of=/tmp/LiloBoot. bin bs=512 count=1

Remember to change the hdxy to the entry in your lilo.conf. This line creates a 512-byte file called LiloBoot.bin in the
/tmp directory (you can name this file anything you want). Copy this file to a DOS floppy using mcopy or by mounting it. Reboot into Win 2000 now.

Copy the Liloboot.bin file to the C:\ folder and make its attributes Read-Only and Hidden. Now open a command prompt and give the command:

attrib –r –s –h c:\boot.ini

After this, open the boot.ini file in Notepad. You should see a few lines similar to 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

Add a line to the end of the file, which looks like this:

c:\LiloBoot.bin="PCQ RedHat Linux 6.2 (Kernel 2.2.14-12)".

The first part specifies which file to use for booting and the second part is the label in the menu. You can use whatever you feel like here. Save the boot.ini file and reset its default attributes to Read-Only, Hidden, and System.

Boot your PC again, and see the label entry you made appear in the Win 2000 boot menu. Select it and press "Enter". You should immediately see the LILO prompt. Continue as you would normally.

Linux pre-installed

If you have a system where Linux has already been installed and you wish to install Win 2000 in some unpartitioned space, it isn’t much of a problem. Make sure you have a boot disk handy for Linux. If not, create one using the mkbootdisk command. Assuming you’re using the PCQ June 2000 Red Hat installation (Kernel 2.2.14-12) use the following command, with a floppy in the drive:

mkbootdisk –-device /dev/fd0 2.2.14-12

Open /etc/lilo.conf in your favorite editor and look for the line that says boot=/dev/hda. This line is the one that says where the boot loader is installed (hda is the MBR). Change this to the partition where the /boot is installed. This is again a very important step. To see which partitions exist, run the fdisk command and type "p" to view the partition table. Note the partition where /boot is installed (not /, unless you installed everything on a single partition) and enter that in lilo.conf. For example, if your /boot is installed on /dev/hda3, lilo.conf should have the entry boot=/dev/hda3. Save the file and issue the command lilo –v. This will write the new LILO.

Now install Win 2000 normally and it’ll overwrite LILO. You can boot into Win 2000 and play around. To get the Linux menu option, boot into Linux using the boot floppy and create the disk image for Windows using dd as given in the previous part. The remaining steps are the same to install the menu.

Both already installed and LILO is the boot loader....>>>

Both already installed and LILO is the boot loader

This means that you had a Win 2k installation, and you went ahead and installed Linux after that and put LILO on the MBR. Which means you lost the NT boot loader (in some cases, Win 2000 refuses to boot even if you enter the appropriate label at the LILO prompt).

Before you go ahead and remove LILO, make sure you have a Linux boot disk handy, by following the instructions in the previous section. Similarly, follow the next set of instructions to "move" LILO from the MBR to the /boot partition.

Now, boot from a DOS or Win 9x floppy that has fdisk on it. Do a fdisk
/mbr from the floppy and reboot. You should now see the Win 2000 boot-up screen. Follow the instructions give in the first part of this article to use the Linux boot floppy to access the partition and create the boot menu entry. Reboot again and use the menu to boot Linux.

Full power ahead

Now that you have Linux as part of the Windows 2000 boot menu, it’s time to make the boot menu even more powerful.

Install the Recovery Console

The Recovery Console is a "DOS-Mode" type tool for Windows 2000 installations that lets you repair a crashed installation. For details read the article "Disaster Recovery in Windows 2000", (page 131) in this issue.

Choose the default operating system

You can select the default OS to boot into by right-clicking My Computer, and clicking the Startup and Recovery button on the Advanced tab. Select the OS from the list and set the amount of time to wait for user input before starting the default OS.

Add the floppy drive to the boot menu for booting

This lets you boot using the floppy from the boot menu, even if you’ve set the boot sequence to C, A in the BIOS. Use this tip only if you don’t need system security, for example, when playing games is all you do on the PC.

Boot into Linux and issue the command:

dd if=/dev/fd0 of=/tmp/Floppy.bin bs=512 count=1.

Follow the same procedure as setting up the Linux installation. Copy this file into c:\ and add an entry to boot.ini like:

c:\Floppy.bin="Boot Floppy".

The next time you boot, this will appear as a new option. Insert a bootable floppy and select this entry to boot from it.

Accessing NTFS from Linux

Having two operating systems can sometimes be a pain. For example, you create, download, or read a file on one operating system, but when you need to refer to the same file later from a different OS, the only way to do this is to copy the file onto a network or floppy, and then copy it back in the other OS. Slow, inefficient and totally anti-technology. Linux does read and write to Win 9x partitions including FAT32, but when it comes to NTFS, it doesn’t even read them. The solution to this is a kernel-level module you need to compile.

First, download the small archive ntfs-990831.tgz from www.informatik.hu-berlin.de/~loewis/ntfs. This is also available in the Linux section of this month’s CD. Follow these steps to install the module:

 

tar zxvf ntfs-990831.tgz (Untar the archive)

cd ntfs (Change to the install directory)

fdiskàp (Note the device on which NTFS is loaded)

./configure —enable-device=<NTFS device name> —enable-mount-to=/mnt/nt (Ready the installation configuration)

mkdir /mnt/nt (Create the directory to be used as a mount point)

make (Compile the installation)

make install (Install)

This should typically work. However, a bug in the install script doesn’t complete the process. To complete the setup, do the following:

cd linux21 (Change to this directory)

make mount (Mount the NTFS partition, creates the NTFS module)

This will mount the NTFS partition to /mnt/nt in read-only mode. Although a configuration option exists for making the mount read-write, it didn’t work for me. To make sure that you can mount the NTFS partition anytime, copy the ntfs.o file from the install directory (ntfs) to /lib/modules/2.2.14-12/fs. Then add the line insmod ntfs to the end of /etc/rc.d/rc.local.

To mount the NTFS partition, simply use mount –t ntfs (NTFS device) /mnt/nt. You can explore the directories and copy files to the Linux partition easily. The installation also has a few other tools (like ntcat, ntcopy, ntdir, etc) that let you use the NTFS partition, without mounting it. If anyone has success in enabling write access, do let me know too.

Accessing Ext2fs from Windows 2000

This is much easier to set up. All you need to do is download the ZIP archive http://uranus.it.swin.edu.au/~jn/explore2fs-1.00-pre3.zip. (also on this month’s CD). Extract and run the single EXE in it. It gives you an Explorer look-alike that reads the Linux partition(s) on your drive, and lets you browse the directories and copy files out. An option lets you enable write-access too.

Hopefully, this article would have helped you not only in letting Win 2000 be the boot choice, but also in understanding how the boot process works. Do let me know about your experiences.

Vinod Unny is with iSquare Technologies


------------------------------------------------------------

Copyright (c) 2010 CMIL All rights reserved. Additional reproduction in whole or in part or in any form or medium without express written permission of CIOL is prohibited.
Send your questions to webmaster@ciol.com

Close this window