Thursday, May 19, 2011

Linux boot loaders

boot loader is a small program used to load an operating system (or "OS") from disk into RAM, pass the OS various parameters, and finally start running the OS.  All operating systems use such a loader.  The boot loader is found by the BIOS code.  It may be on a boot-floppy, in the MBR (master boot record), or in the boot-blocks of any bootable partition.
There are many different boot loaders available.  Some provide GUI menus and many options, others provide no interface at all.  For example the first sector (512 or 4096) bytes of the Linux kernel contains boot loader code, so if a Linux kernel is copied onto a floppy disk the kernel will boot!  Fancy
commercial boot loaders are available such as "Boot Magic" (comes with "Partition Magic") and "System Commander".  MS Windows and Solaris each come with boot loaders that can be somewhat configured to provide a menu of bootable partitions.
If a boot loader is installed in the MBR and a problem arises, the system will not be bootable.  For such a situation it useful to keep a DOS bootable floppy disk around containing the DOS program "fdisk.exe".  The DOS version of fdisk allows an (undocumented but widely known) option.  Running "fdisk/MBR" will over-write the MBR with a fresh, vanilla version.  Hopefully this will allow at least one of your operating systems to boot normally.  You can then use various tools to fix the problem.  (A boot floppy for each of your installed operating systems kept near the server is a handy precaution to take.)


The most flexible (and common) boot loaders are "LILO" and "GRUB".  Of these LILO ("LInux LOader") is older and less powerful.  Originally LILO did not include a GUI menu choice (but did provide a text user interface).  To work with LILO an administrator would edit the file /etc/lilo.conf, to set a default partition to boot, the time-out value, which choices should appear in a menu, kernel parameters, which partition to mount as the root partition, whether or not to initially load a RAM disk, where LILO should be installed, and other information.  (See the man page for "lilo.conf".)  After editing this file the administrator must then update the loader by running the lilo command.  Doing so updates either the MBR or the boot blocks (according to where lilo.conf says the loader is to be installed).
GRUB is a bit easier to administer because the GRUB loader is smart enough to locate the /boot/grub/grub.conf file when booting.  So an administrator only needs to install GRUB once, using the "grub-install" utility.  Any changed made to grub.conf will be automatically used when the system is next booted.  (See the info page for grub for details.)
Linux systems must use a Linux-aware boot loader, usually LILO or GRUB.  If you setup a dual-boot system and choose to use some other boot loader, say a commercial one or the Windows boot loader, you must also use LILO or GRUB.  In this case you would install your main boot loader in the MBR, and the Linux boot loader in the boot-blocks of the Linux bootable partition.  When the main boot loader runs and the user chooses to boot Linux, rather than try to run the kernel directly the main boot loader will look for a (secondary) boot loader in that partition's boot blocks.  (Note in this setup the secondary boot loader is usually configured to not display a menu, although it certainly can be setup that way.)
Even today some home PCs and portable computers ship with hardware for which only Windows drivers are available.  This situation is changing but it may be a problem for some home users (on a server who cares about video or sound cards).  One way to deal with this situation is to setup a bootable DOS partition that contains the correct drivers.  Then you can put a special command "LOADLIN.EXE" as the last statement in the AUTOEXEC.BAT file.  LOADLIN is a program that will boot a Linux partition without re-initializing the hardware.  So you can use this setup to load in DOS, which then initializes your hardware, then load in Linux.

GRUB Issues:
1- Insert the Ubuntu live CD then run the live side Mode
2- Open the terminal emulator SHELL
3- Write this command
>> grub

>> find /boot/grub/grub.cfg Ubuntu10.10 and 10.4 releases and older
>> root (hd0,6) # 6 represent the sda# (number)
>> setup (hd0)
>> reboot
4- then open the file called menu.lst
>> gedit /boot/grub/menu.lst
5- Edit the file as follow:
title Sucs Windows7
rootnoverify (hd0,3)
chainloader +1
Note: for Ubuntu11.4 release the edited file is /boot/grub/menu.lst Not grub.cfg

No comments: