November 24, 2024, 03:21:28 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Using the NT/2k/XP/2k3 bootloader to boot Linux (B)  (Read 31007 times)

Offline aaa

  • Tux Awared
  • **
  • Posts: 38
Using the NT/2k/XP/2k3 bootloader to boot Linux (B)
« on: January 16, 2004, 05:07:53 PM »
So maybe you're no so sure about installing some boot loader to your Master Boot Record (MBR), out of the fear of not being able to boot Windows. Don't worry! If you have Windows NT/2000/XP/2003, you can use their 'NTLDR' bootloader to boot Linux. How? The same way the NT operating systems boot dual-boot with older versions of Windows, like 95/98/ME. During installation, the NT os would copy the first sector of the previuos Windows' partition, called the boot sector, to a file called 'bootsect.dos'. It would then install it's own booloader to this bootsector. In the bootloader configuration file, 'boot.ini', it would add this line:
Code: [Select]
C:\ = "Windows 98"
Or:
Code: [Select]
C:\bootsect.dos = "Windows 98"

   The NT os would then chain-load the older Windows' bootloader, now in the 'bootsect.dos' file. It would also have an entry called "Windows 98" in a menu that will pop up at boot. Fortunately, it is very easy to do the same for other bootloaders, not just the Win9x bootloader. You can do this with the Linux bootloaders, GRUB or LILO, in a few simple steps:

o Copy the Linux bootloader to a file.
o Copy the file to Windows 'C:\'.
o Add an entry to 'C:\boot.ini', the Windows bootloader configuration file.


Please note that almost of all of the procedures described here require you  to be the root user.

Linux Bootloader Installation

   Your particular Linux distribution's installer probably has a few options regarding where the Linux bootloader will be installed. They typically are 'MBR', 'Root partition' or 'Linux Partiton', and 'Floppy'. If you haven't installed the bootloader yet, choose 'Root' or 'Linux Partition'. This installs to the bootsector of the Linux partition, without altering the Windows boot setup. If you have the Linux bootloader already installed to the MBR (Master Boot Record) of your hard disk, you can still use this procedure, but in a slightly different way. Installing to floppy may not work with this procedure.

   If you have already finished the installation and are booting from a floppy or similar, you can install the bootloader yourself. I'm not sure what the names of all tools the various distros use to configure their bootloaders, but here are some instructions that should work for all of them.

   For LILO, you need a /etc/lilo.conf file. To make one, you can:
o Use the various tools many distros provide useful tools to make this file. o How to use them can be found out at your distro's site.
o You can use KDE's tool for making the lilo.conf file, in it's control center (kcontrol).
o There is also the 'liloconfig' program.
o You can also look at the lilo.conf manual page (command: 'man lilo.conf')  to help you make it yourself.
Once you have the lilo.conf file, open it with a text-editor as root user and make sure that it has this line:
Code: [Select]
boot=/dev/hda2
This assumes that your Linux partition is /dev/hda2. LILO will be installed there later. You probably don't want 'boot=/dev/hda', this'll install to the MBR, & you probably don't want 'boot=/dev/hda1', because this is the partition is where the Windows partition often is, and you don't want to erase the Windows bootloader that resides there.
Once your /etc/lilo.conf file is ready, you can run LILO (command: 'lilo') to install LILO. Now LILO will be installed to the bootsector of /dev/hda2 (if you chose it).

   For GRUB, you need to install in a different manner compared to LILO. You can use the usual tools, often provided with many distros. Make sure you install to the bootsector of a partition, not the MBR. You can use grub-install to install: 'grub-install /dev/hda2', or just plain GRUB: 'grub', then 'setup (hd0,1)' (for hda2), then 'q' to quit. Check the GRUB manual to read up on GRUB's naming convention.



Copying your Linux bootloader to a file

   After installing your bootloader to the bootsector of a partition, you can copy it to a file. If you used 'boot=/bootsect.lnx' with LILO, you don't need to do this, you already have the needed file. You copy the bootloader from a partition using the 'dd' command (example for partition hda2):
Code: [Select]
dd if=/dev/hda2 of=/bootsect.lnx bs=512 count=1
This'll copy the first sector or 512 bytes of hda2 (it's bootsector) to the file 'bootsect.lnx' in the / directory. If you installed your bootloader to your partition, it will now be copied to the 'bootsect.lnx' file.



Copying the bootloader file to Windows

   If you use FAT32 for your Windows partition, then you can copy the file directly to it in Linux. First it needs to be mounted to a folder, say, /mnt/win :
Code: [Select]
mount /dev/hda1 /mnt/win -t vfat
This assumes that Windows considors /dev/hda1 to be it's 'C:\'  drive.
Then you can copy the file:
Code: [Select]
cp /bootsect.lnx /mnt/win
   If you use NTFS, then you'll have to copy via floppy. Get a Windows-formatted floppy. Mount it, to /mnt/floppy:
Code: [Select]
mount /dev/fd0 /mnt/floppy -t vfat
Then copy:
Code: [Select]
cp /bootsect.lnx /mnt/floppy
Reboot into Windows, & copy the file to the 'C:\' drive.

Editing boot.ini
   Now you need to edit your C:\boot.ini file. It is problematic to do this from Linux, because DOS text is slightly different from UNIX text, and you wouldn't be able to save to NTFS. There are some text editors that can save DOS text, though. In Windows, this file may be hidden. You an unhide it by clicking on Tools=>FolderOptions, and turn off the 'Hide system files' option in Explorer, or you can access it via the Control Panel's System tool ([right-click]MyComputer=>Properties=>Advanced), or via the msconfig program, in the 'boot.ini' tab. Add this line to boot.ini:
C:\bootsect.lnx = "Linux"
Now, the next time you bootup, you'll see a menu asking whether to boot Windows or Linux.




v0.3 (4/7/04) -- corrected grammar,  changed linux.bin to bootsect.lnx for consistency
v0.21 (1/16/04) -- original post

Offline FrankE

  • New Member
  • Posts: 1
Even easier...
« Reply #1 on: April 01, 2004, 08:53:54 AM »
Follow the above howto, but instead of manually copying the linux bootsector and editing the boot.ini file in Windows, download BootPart from http://www.winimage.com/bootpart.htm and use it to create the Linux bootfile and configure the boot.ini automatically. It's a much easier way that seems to give rise to far fewer problems.