####[ How-Do-I Documents ]####################################### Sub : Using NT Boot Loader to boot Linux HDI - 002 ################################################################# Contents: 1. LILO and dual boot 2. Why use the NT loader 3. Preparing for dual installation 4. Install Windows-NT 5. Install Linux 6. Linux part of job 7. Then in Win-NT 8. Installing other Operating Systems 9. Bootpart 10. Kudos and brickbats ################################################################# 1 LILO and dual boot 1.1 There is a tendency amongst most Linux users to consider LILO (Linux Loader) as the "pure" Linux booting system and therefore do all sorts of re-arrangements within their own systems to accommodate LILO ... Nearly all distros (except for the ones operating from UMSDOS partitions), install LILO as the default boot loader, irrespective of the fact that the performance of LILO is at best average under some dual boot / multi-boot conditions. 1.2 When it comes to NT, the main problem arises from the fact that Linux as of now cannot access NTFS partitions, though drivers are under development ( http://www.informatik.hu- berlin.de/~loewis/ntfs ). Secondly, the boot process in NT is at variance with the Win-9x systems, having its own boot loader which cannot be fired off from LILO using the "other" label in lilo.conf. 1.3 Under such conditions, I would always advocate the use of other boot loaders.In the case of NT, I would advocate the use of NT boot loader itself. 1.4 Besides the elegance of the boot process, you have the advantage that there is no messing with the MBR with LILO specially when NT is loaded on /dev/hda1 ... There are no warnings received from few virus checkers when they find a non-M$ boot sector on MBR ! 2 Why use the NT Loader ? 2.1 Boot sector of any Operating System essentially calls the code, somewhere within its own partition to continue with the boot process. Essentially the boot sector has execu- table code (along with other basic info) ... This code is strictly in x86 machine code, and therefore independent of any OS. 2.2 The NT boot loader makes use of this fact, and is able to execute any such code, if available as a file within its own NTFS partition ... It has a configurable text file by the name of boot.ini, which can be used to fire the other operating systems using their own boot mechanisms. 2.3 The only QR being that the boot sector of the alien OS in its "raw" executable form should be available in its NTFS partition, irrespecive of what the OS is. The subsequent boot process is done using the native boot mechanism of the concerned OS. 3 Preparing for a dual installation. 3.1 When preparing for a multi-boot installation having Linux NT and probably a 3rd OS (Win 9x, Win-2k or QNX etc). It is best to formulate a plan about how to go about frag- menting your disk. It is beyound the scope of this docu- ment to digress into those areas. 3.2 Ony one point needs to be emphasised, is that each boot- able OS should have its installation root in a *PRIMARY* partition. This is necessary because boot info may have to be written on them seperately. An IDE drive can have a maximum of four primary partitions, or three primary and one extended partition. The extended partition may then be subdivided into numerous logical partitions but shared between them there is only one boot record, the one belo- nging to the mother extended partition. 3.3 Setting the partitions 3.3.1 There are two types of situation here. Firstly, where all operating systems are installed on a clean hard disk. And secondly, where Win-NT may already be existing on it with data which you can ill afford to lose. In the second case the extended partitions would have to be deleted to make space for the Linux installations to follow. 3.4 Marking the partitions 3.4.1 This needs to be done through Linux fdisk. The fdisk which comes with MS-DOS or NT cannot make Linux partitions. The tools available at this stage is to use: a) Rescue disk sets of any distro (e.g. Slackware root and boot disk sets, Debian rescue disk) and depending upon the Linux flavour you wish to install, their boot disks themselves provided they give scope for the Linux fdisk program to be run in the beginning, and quitting with no further installation. b) Use stand alone disk based distros like alfalinux or Toms root/boot disk (http://www.toms.net/rb/). 3.4.2 After booting through the rescue disk run the fdisk program which invariably comes with the rescue disk set. Mark the partitons as per your installation plan. In case Win-NT is preloaded in /dev/hda1, this may be shown as Type 7. Linux fdisk assumes the ntfs-partition to be a HPFS-partition ! This is normal. Ignore. Other extended partitions need to be deleted before fresh ones are created/ marked. 3.4.1 For a clean state installation, mark your partitions as per your plan. Since you would be booting through NT loader no consideration needs to be given about the 1024th cylinder boundary. 3.4.2 The partitions where you want Win-NT to be loaded should be marked (Type 6 or Type 7). Normal ext2 partitions for load- ing Linux should be marked Type 83, and one small partition meant for Linux swap (Type 82). Make sure you keep at least one extended-logical partition as Type 6 (DOS 16 bit). This would be needed to share data between NT and Linux ... This partition will be seen as D: after NT is loaded. Creating this partition is extremely important, since this would be needed for data transport between the two OSs. 3.4.3 Convert this partition to MS-DOS immediately. NT cannot do a FAT-16 format. Through Linux it is easier. At this stage do: mkfs /V -t msdos /dev/hdaN (where N is the no of partition) 3.5 Once this part has been done, basic preparation for install is ready. Exit out of the rescue disk session ... 4 Install Windows NT 4.1 Install Windows NT first, using the normal convention. You will notice that C: (/dev/hda1) and D: (/dev/hdaN) are seen Install NT on C: alone. Ensure that a boot disk is created, and ensure that NT is functioning normally. 5 Install Linux 5.1 There is nothing different from a normal Linux installation only that you need not create the partitions again and just mount them as per your plan and proceed ... It is advisable that "/" is kept on a *PRIMARY* partition because the boot record needs to be written there. 5.2 There are only three things to look out for: a) Some smart distros suggest mounting the HPFS partition which it detected as part of the installation process - IGNORE it. b) Always make a boot disk (if not two) ... You would need this to boot into Linux till the NT boot loader has been charged with this duty. c) DO NOT place LILO on the MBR. Write LILO information on the boot-sector of the partition (usually /dev/hda2). 5.3 Once the boot-sector info has been written, either before you quit (if your installation permits shell access) or on first boot from floppy, ensure that the root-entry and the boot-entry in /etc/lilo.conf is in consonance. If you have an IDE HDD and your "/" partition is in /dev/hda2, then the entry in /etc/lilo.conf should look like this: boot=/dev/hda2 5.4 You would have to boot Linux through disk at this stage. 6 Linux part of job 6.1 Things to be done are: a) Create a raw file of the boot-sector image b) Make a mount point for 16 bit DOS partition c) Copy file to 16 bit DOS partition 6.2 To create a raw file of the boot-sector of the Linux root partition (/dev/hda2 for example), you need to do: #dd if=/dev/hda2 of=/bootsect.img bs=512 count=1 This will extract exactly 512 bytes of the boot sector of /dev/hda2 and place it in a file called bootsect.img, under the root directory. Ensure that the filename you give con- forms to 8.3 convention because it needs to be transported over a MS-DOS 16 bit medium. 6.3 Since you cannot directly copy this file to the NTFS parti- tion where the NT system lies, we need to go through the 16 bit partition we created (or carry over a floppy). #mkdir /mnt #mkdir /mnt/DOS-D #mount -t msdos /dev/hdaN /mnt/DOS-D #cp /bootsect.img /mnt/DOS-D/ #umount /mnt/DOS-D 6.4 The Linux job is over, we can quit. 7 Then in Win-NT 7.1 Copy the file from D:\bootsect.img (or floppy) to Win-NT partition. Keep it safe in a directory (say C:\BootImg). 7.2 Edit C:\boot.ini. This is a system, readonly file. To edit this, the attributes need to be changed. Go to a DOS shell: C:\>attrib -s -r c:\boot.ini C:\>edit boot.ini 7.3 Change the file boot.ini with edit (or notepad if in GUI), as follows: ------------<snip>---------------------------------------- [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="Windows NT ..." multi(0)disk(0)rdisk(0)partition(1)\WINNT="Windows NT ..." C:\BootImg\bootsect.img="My Linux" ------------</snip>--------------------------------------- 7.4 Note : Only the last line has been added. The rest is as it was originally. Restore the attributes after saving. C:\attrib +s +r c:\boot.ini 7.5 The next time you boot, you should see something like: --------------<snip>------------------------- OS Loader V4.00 Please select the operating system to start: Windows NT Workstation Version 4.0 Windows NT Workstation Version 4.0 [VGA mode] My Linux --------------</snip>------------------------- 7.6 If you select "My Linux", you will see the familiar ... LILO loading vmlinuz .... 7.7 Note: you need to repeat this proceedure every time boot- sector info changes, e.g. Installing a new kernel. 8 Installing other Operating Systems 8.1 As long as you have Linux and NT running, any OS running from its own primary partition, can be made to run this way If you have QNX on /dev/hda3, repeat steps above, only that the partition id and filename will change: dd if=/dev/hda3 of=/mnt/DOS-D/qnxboot.img The NT procedure remains the same ... 9 Bootpart 9.1 There are several people who are new to Linux and would like to tread on familiar waters. There is a Win-NT program called "bootpart" written by G Vollant that can do the same thing from NT directly, with no need to bother about going into Linux to get a boot sector image, or having to change attributes of boot.ini for editing. The URL is: http://ourworld.compuserve.com/homepages/gvollant/bootpart.htm ################################################################# 10 Kudos and Brickbats 10.1 This document is released under GNU/ GPL licence. You are free to use and distribute this without any encumberances 10.2 Any kudos and brickbats should be directed at: USM Bish <bish@nde.vsnl.net.in> 23 Sep 2001