Parent page to http://pgtips91.pbworks.com/Step-by-step-instructions-for-the-target-system
This project has arisen out of the saga that developed at Linux Internationals, here: --
[Note, this morphed into a long discussion on booting problems between Xandros, Pardus and Win98]
When multi-booting from several installed operating systems, each of which uses a different boot-loader, different file systems and all competing with one another to control the MBR, there are a number of problems that may ensue if not guarded against and provision made for the complexity of the situation.
The order in which the Operating Systems are installed has a dominant influence over which boot-loader is installed to the MBR and is therefore the controlling boot-loader at time of booting up.
However, once the system is fully installed there are ways and means by which the system can be conformed to the wishes of the user, regardless of how the defaults have laid out the system up until this point.
MBR [Master Boot Record]
Operative Boot-loader
Layout of Partitions
Boot-loaders :
LILO
GRUB Legacy
GRUB-PC
Distributions
What you need to do, to regain full control over your system, is explicitly make these choices and implement them : --
Thus MS Windows boot-loader needs to be called by GRUB to boot MS Windows, and GRUB-PC needs to be called by GRUB Legacy if the target OS has been installed with a file system that is not recognised by GRUB Legacy, such as ext4 for example.
To avoid messing up this system, when installing or re-installing an OS later on, ensure that you install the boot-loader only to the root of the partition where the OS is being (re-)installed and avoid over-writing the MBR. This is usually possible by selecting the advanced options during the installation process. Watch carefully for this option at the stage where you select the partition(s) into which to (re-)install the OS because if you miss this option you will have quite a lot of work to do to recover your system. Often the option is difficult to find, being hidden from inexpert users.
Typically, if you have a version of MS Windows installed, this will have been installed first and occupy the first partition on the system. I will assume that this is the case from here on.
The partitioning system has an archaic limitation of four primary partitions. In order to have more than four partitions on a hard drive, therefore, it is necessary to have one of these partitions dedicated as an extended partition. The extended partition can then be sub-divided into any number of Logical Partitions as needed [there is a limit but this will seldom be a problem].It is best to reserve the 4th partition for this so that any Logical Partitions added or deleted do not affect the partition table adversely.
It is possible, and desirable, to keep your personal data, such as emails, documents, photographs, downloads, etc, on their own data partition(s). This should be distinguished clearly from what the OS will store in your /home/username directory. The latter stores a lot of needed information that is very specific to the installed operating system but is strictly not personal data in the full sense. There is a way to keep these two significantly different forms of data separated, avoiding many problems including : --
* duplication or lack of access to data between the various operating systems,
* loss of data when re-installing an operating system
To see more on this topic in depth, refer to the on-line tutorial at http://sblinux.org/pages/symlink-home.html or alternatively at http://www.gnulinuxuser.net/2-cu/data-01.html
For the sake of this tutorial, I will create an illustrative partition layout which will then form the basis of this tutorial hereafter.
The first partition of the first hard drive will be referred to variously, by GRUB Legacy as (hd0,0), by GRUB-PC as (hd0,1), by LILO as (), by MS Windows as '\:C', by Linux as hda1
Here then is the layout, in Linux terminology.
Primary 1 hda1, file system FAT32 [or vfat], MS Windows 98, XP, Vista, 7
Primary 2 hda2, Main Other OS
Primary 3 Swap partition [at least double your installed RAM ]
Primary 4 Extended Partition
Logical 5 Data 1, emails, documents, PIM, etc
Logical 6 Data 2, Photographs, Video clips,
Logical 7 Data 3, Downloads
Logical 8 Backups of personal data
Logical 9 Experimental OS installation 1
Logical 10 Experimental OS installation 2
You get the idea!
I'll assume that MS Windows was installed first, occupies the entire hard drive and has control of the MBR initially. You may be able to re-size the MS Windows partition and create the partitioning I have shown, or it may be necessary to add a second hard drive for the additional partitions and leave MS Windows to its own. These days Linux has no difficulty in mounting a partition that has been set up by MS Windows, in either FAT32 or NTFS file format, meaning that you can access your personal data there from within a Linux installation later on. But if you are starting from bare metal, installing MS Windows yourself and then the other operating systems, then the layout in my example is straight forward to implement.
Starting conditions : --
robert@robert-pardus ~ $ blkid
/dev/sda1: LABEL="WIN98" UUID="1724-16EF" TYPE="vfat"
/dev/sda3: UUID="86d22688-98e1-419e-8aa4-252eb2802238" TYPE="swap"
/dev/sda4: LABEL="XANDROS" UUID="de66e74a-a7c6-457c-a2ca-8567d5b7ce7b" TYPE="reiserfs"
/dev/sda5: LABEL="UTILITIES" UUID="1569-19E6" TYPE="vfat"
/dev/sda6: LABEL="PARDUS_ROOT" UUID="2f2e8162-b0bc-426e-bab4-de60b7aa364d" TYPE="ext4" [ _______________Note : The UUID is changed each time the partition is reformatted
/dev/sda7: LABEL="PARDUS_HOME" UUID="96847a79-b707-4351-b6fd-9ed74ea9505c" TYPE="ext4" [ _______________Note : The UUID is changed each time the partition is reformatted
/dev/sda8: LABEL="APPLICATION" UUID="4560-A577" TYPE="vfat"
/dev/sda9: LABEL="GAMES" UUID="2F2D-0F0B" TYPE="vfat"
robert@robert-pardus ~ $
LILO stands for LInux LOader, and was the standard boot loader for Linux until GRUB came into vogue. It is more simple than GRUB and is still preferred by some users, but it is getting left behind with recent developments.
GRUB stands for 'GRand Unified Bootloader' and has been almost universally adopted by Linux distros for some time. The older versions are now being overtaken by the latest major revision and re-design of the application, being called GRUB2 or more recently GRUB-PC
This is the latest development of the GNU GRUB utility and is being increasingly used with later releases of Linux.
MBR stands for Master Boot Record. It is located in the first sector of the first hard disk or a floppy disk. It contains a small program that is read into memory and executed at boot (after the BIOS bootup). The program tries to find a bootable partition in the partition table (which is located in the end of the MBR sector). The boot sector of the partition is then loaded and executed. This normally is some boot loader but can also be an actual kernel of some specific OS. In Linux LILO or GRUB is usually installed in the MBR.
In linux the MBR can be directly accessed with dd. For example to make a backup of the MBR:
# dd if=/dev/hda of=/path/mbr-backup bs=512 count=1
and restore it with
# dd if=/path/mbr-backup of=/dev/hda bs=512 count=1
Change hda to sda for SCSI or SATA drives.
Change to the a of hda to b or c etc for drives on other controllers.
Read more: http://wiki.linuxquestions.org/wiki/MBR#ixzz0wfK2Njlo
Here's a how-to for chain-loading LILO from GRUB Legacy : --
If you want to boot an unsupported operating system (e.g. Windows 95), chain-load a boot loader for the operating system. Normally, the boot loader is embedded in the boot sector of the partition on which the operating system is installed.
grub> rootnoverify (hd0,0)
grub> makeactive
grub> chainloader +1`+1' indicates that GRUB should read one sector from the start of the partition. The complete description about this syntax can be found in section How to specify block lists.
However, DOS and Windows have some deficiencies, so you might have to use more complicated instructions. See section DOS/Windows, for more information.
Here is a how-to for GRUB Legacy Grub From the Ground Up
While running an installed Linux you can examine the current state of the menu.lst file, by running the following command in a Konsole window : --
sudo grub --config-file \(hd0,0\)/boot/grub/menu.lst [Note the '\' 'escape character' otherwise GRUB cannot parse the command.]
paul@paul-ArtistX07:~$ sudo grub --config-file \(hd0,0\)/boot/grub/menu.lst
[sudo] password for paul:
Probing devices to guess BIOS drives. This may take a long time.
paul@paul-ArtistX07:~$
This produced, in the Konsole window, the familiar black window with boot options, in fact a virtual GRUB! Everything works the same as at boot-up except that, as far as I can tell, it will not boot anything.
Here is a mini-how-to for LILO LILO mini-HOWTO
This tutorial gives a very useful method of creating either a floppy disk or a CD which can be used to boot all the operating systems that have been installed on the computer. This is a useful exercise to learn about the process, it is also useful for booting external drives and as a rescue disk if anything should go wrong with the boot-up process in the future.
Read more at the above link [the heading]
When an operating system has been installed with the boot-loader installed to both the MBR and the root file system, then that partition needs further attention to make it bootable from another boot-loader that now is installed to the MBR.
Here are the instructions, for LILO and GRUB, to copy the data from the MBR to the root partition and make it bootable with chainloading.
The "sole" necessary condition for Grub to chain-load a system is that the system must have its own boot code or boot loader inside the boot sector of its own partition. This is automatically arranged in the installation of any MS system, BSD and Solaris. In GNU/Linux a choice is often given by the installer to be either in the MBR or in the root partition. The two are the same if the Linux resides in hda1. If a Linux has placed its boot loader in the MBR then its boot code can be replicated in root partition, say it is the hdc39 partition, by
grub-install /dev/hdc39
or
lilo -b /dev/hdc39
depending on its boot loader being Grub or Lilo respectively.
I will show this as a separate page for ease of printing and following.
Read more at the above link [the heading]
In order to backup only the first few bytes containing the MBR and the partition table you can use dd as well.
dd if=/dev/hdx of=/path/to/image count=1 bs=512
dd if=/path/to/image of=/dev/hdx
Add "count=1 bs=446" to exclude the partition table from being written to disk. You can manually restore the table.
end
When Lilo overwrites a boot sector, it saves a backup copy in /boot/boot.
xxyy, where xxyy are the major and minor numbers of the device, in hex. You can see the major and minor numbers of your disk or partition by running ``ls -l /dev//device''. For example, the first sector of /dev/hda
(major 3, minor 0) will be saved in /boot/boot.0300
, installing Lilo on /dev/fd0
creates /boot/boot.0200
and installing on /dev/sdb3
(major 8, minor 19) creates /boot/boot.0813
. Note that Lilo won't create the file if there is already one so you don't need to care about the backup copy whenever you reinstall Lilo (for example, after recompiling your kernel). The backup copies found in /boot/
are always the snapshot of the situation before installing any Lilo.
If you ever need to uninstall Lilo (for example, in the unfortunate case you need to uninstall Linux), you just need to restore the original boot sector. If Lilo is installed in /dev/hda
, just do ``dd if=/boot/boot.0300 of=/dev/hda bs=446 count=1'' (I personally just do ``cat /boot/boot.0300 > /dev/hda'', but this is not safe, as this will restore the original partition table as well, which you might have modified in the meanwhile). This command is much easier to run than trying ``fdisk /mbr'' from a DOS shell: it allows you to cleanly remove Linux from a disk without ever booting anything but Linux. After removing Lilo remember to run Linux' fdisk to destroy any Linux partition (DOS' fdisk is unable to remove non-dos partitions).
If you installed Lilo on your root partition (e.g., /dev/hda2
), nothing special needs to be done to uninstall Lilo. Just run Linux' fdisk to remove Linux partitions from the partition table. You must also mark the DOS partition as bootable.