saikee
11-03-2007, 10:04 AM
Moral of the story : Whoever knows how to boot an operating system manually never has a booting problem in a PC.
--------------------------------------------------------------------------------------------------------
This thread was written for a situation when you have
The incumbent boot loader in the Linux is not bootable
The Linux was installed without a boot loader, possibly by mistake or an error in the install.
You don't like its boot loader and want to try another
You want to boot up a Linux manually step by step to feel the power of being in control
I shall assume your Linux has been installed in a single partition first and describe the additional steps if it isn't, in the later Complications section..
Summary of steps
Step-1 : Obtain a Grub prompt - meaning you now use Grub to boot it.
Step-2 : Check the partition information and find out where is your unbootable Linux.
Step-3 : Boot up the Linux manually- yes, every PC system can be booted manually if you try!
--------------------------------------------------------------------------------------------------------
Step-1 : Obtain a Grub prompt
I have devoted a Section J to show how a Grub prompt can be obtained in the Just Booting Tips (http://www.justlinux.com/forum/showthread.php?t=144294). The last one Task J4 using a selected Live CD is possibly the easiest. You simply boot one up, press "Esc" and "c" key to get a Grub prompt.
In a Grub prompt no operating system has been booted up yet. You are talking to Grub directly and have its full attention. No middleman involved. Grub has to do everything you wish it to do. The trick is to know the commands and only a few would be enough to get by.
Step-2 : Check the partition information and find out where is your unbootable Linux.
THis command in a Grub prompt displays every partition of the 1st hard disk in the booting queue.
geometry (hd0)
Grub counts from zero so if you have more hard disk simply type "geometry (hd1)" for the 2nd disk, "geometry (hd2)" for the 3rd disk and so on.
I assume from the partition display you will be able to see where is your Linux. Since a regular Linux must have a partition Type 83 the first one you can see from your display will be most likely the unbootable Linux. This information may help you to understand various partitions
Fat16 has Type 6 or e
Fat32 has Type b or c
NTFS has Type 7
Linux has Type 83
Swap has Type 82
LVM has Type 8e
So I shall assume by reading off the partition display you can identify the first partition with type 83, say this is (hd0,3) which is the 4th partition of the 1st hard disk. In modern Linux the device name will be sda4. Older Linux may call it hda4 if it is on a Pata disk.
Step-3 : Boot up the Linux manually.
There are only 4 commands needed to boot a Linux; "root", "kernel", "initrd" and "boot".
(1) Define the root partition of the unbootable Linux (using (hd0,3) for example but do adjust it to suit your circumstance) by command
root (hd0,3)
(2) Type the "kernel" command, half-guess the kernel name starting with "/boot/vmlinuz" and let Grub to find the rest. You therefore type at a Grub prompt
kernel /boot/vmlinuzbut do not press return. Instead you hit the "tap" key. Grub will search all the files that match the front end name of "vmlinuz" in the directory of /boot inside the partition (hd0,3) . There may be several choices. Select any one (usually the one without a tail is symbolic-linked to the most recent kernel so use it) and type the full name and add "ro root=/dev/sda4" like this
kernel /boot/vmlinuz-??????????-???? ro root=/dev/sda4
This is the simplest way of booting up a Linux. The -??????????-???? is generated by Grub. You don't need to type it! See example later.
(3) Repeat Step (2) but for the "initrd" command. You hit the "tap" after finishing typing
initrd /boot/initrd
There could be several choices offered by Grub just choose one that has the same tail. Add characters to uniquely define the file name and press "tap" key again to let Grub to finish the typing. You should end up with something like this
initrd /boot/initrd-??????????-????
(4) Give the green light to Grub to fire up the Linux
boot
If you receive no objection or complaint from Grub then you should be greeted by the Linux without using its boot loader.
Conclusions
If you manage to boot up a Linux mannually without using its boot loader you open the door to the following
You can boot up most Linux this way, probably not the most optimum way but it certaily works.
You now know how to convert a Linux previously booted by Lilo to be booted by Grub. You can "cat /etc/lilo.conf" and use this information to convert the booting instructions on-the-fly.
You now know the Grub's menu.lst or grub.conf contains very instructions that you need to boot that system manually.
You should now realize that you can boot any PC system of Dos, Windows, Linux, Solaris and BSD manually if you just use chainloading.
You have just kissed all your booting problems good-bye.
--------------------------------------------------------------------------------------------------------
Examples - including all major Linux families of Ubuntu, Suse, Ferdora, Debian, Slackware and Mandriva.
The commands that I "manually" boots my Kubuntu 7.10 in a single partition sdb10 (known to Grub as (hd1,9)) in a Grub prompt are
grub> root (hd1,9)
grub> kernel /boot/vmlinuz-2.6.22-14-generic ro root=/dev/sdb10
grub> initrd /boot/initrd.img-2.6.22-14-generic
grub> bootThe green bits are generated wholly or partly by Grub via the "tap" key. The above works equally well for my Ubuntu 7.10 in sda6 (by changing to "root (hd0,5)" and "root=/dev/sda6")
My Debian 4r0 in sda11 is bootable with manual commads
grub> root (hd0,10)
grub> kernel /boot/vmlinuz-2.6.18-5-686 ro root=/dev/sda11
grub> initrd /boot/initrd.img-2.6.18-5-686
grub> boot
For my Fedora 7 in sdb6 and Mandriva in sdb10 (changing to "root (hd1,9)" & "root=/dev/sdb10"), both of which have standard vmlinuz and initrd.img names, I could fire each up with
grub> root (hd1,5)
grub> kernel /boot/vmlinuz ro root=/dev/sdb6
grub> initrd /boot/initrd.img
grub> boot
My OpenSuse 10.3 in /dev/sdb5 is a bit special and uses the swap, which is sda5 in my case, to assist it booting. After I found it out in its menu.lst I fire it up manually by adding an extra parameter resume=/dev/sda5
grub> root (hd1,4)
grub> kernel /boot/vmlinuz ro root=/dev/sdb5 resume=/dev/sda5
grub> initrd /boot/initrd.img
grub> boot
The Slackware is possibly the easiest to boot because it has no initrd and uses the standard kernel name "vmlinuz" The Slackware 12 in my sda7 was booted by
grub> root (hd0,6)
grub> kernel /boot/vmlinuz ro root=/dev/sdb7
grub> boot
--------------------------------------------------------------------------------------------------------
Complications
(A) Linux installed in multiple partitions (particularly relevant to Red Hat distros) - If you have installed the Linux in more than one partition then it is likely that the first Type 83 partition is just its /boot directory. You then need to look for the second Type 83 partition or Type 8e partition (if you use a LVM). You need to implement the follow changes to the instructions above.
(a) No need to use /boot infront of the kernel and initrd file name. For example instead of typing
kernel /boot/vmlinuzyou just need
kernel /vmlinuz
(b) You have to specify the /boot partition with the Grub's "root" command and the "/" partition with the "root=/dev/???" parameter in the kernel statement. Lets assume your /boot is (hd0,3) and the root filing system "/" of your LInux is in (hd0,5) which would be known in Linux as sda6 then you should boot your Linux with statements
grub> root (hd0,3)
grub> kernel /boot/vmlinuz-???????????? ro root=/dev/sda6
grub> initrd /boot/initrd.img-????????????
grub> boot
(B) Linux installed into a LVM - The treatment is same as (A) above except you can identify the LVM partition by Type 8e. The "root=/dev/????" parameter in the kernel statement should be pointing to the LVM partition. Linux boot loaders Grub and Lilo cannot read a LVM and so every distro using a LVM must has a separate /boot partition to store the kernel and initrd files outside the LVM for the boot loader for access.
(C) Non-standard kernel names - A handful of distros do not use the standard kernel name starting with "vmlinuz" or the initrd name starting with "initrd". Luckily they are the odd ones out. Gentoo and DSL are the two culprits. You may need to boot up a Live CD to mount its /boot to look for the kernel name. For example DSL on 2.4 kernel consistently names its kernel as "kernel24"
(D) Distros that does not have ram disk file initrd - Some distros, especially those from the Slackware and Slax families can have one large kernel and no initrd. Just omit the initrd statement in booting any of them.
--------------------------------------------------------------------------------------------------------
This thread was written for a situation when you have
The incumbent boot loader in the Linux is not bootable
The Linux was installed without a boot loader, possibly by mistake or an error in the install.
You don't like its boot loader and want to try another
You want to boot up a Linux manually step by step to feel the power of being in control
I shall assume your Linux has been installed in a single partition first and describe the additional steps if it isn't, in the later Complications section..
Summary of steps
Step-1 : Obtain a Grub prompt - meaning you now use Grub to boot it.
Step-2 : Check the partition information and find out where is your unbootable Linux.
Step-3 : Boot up the Linux manually- yes, every PC system can be booted manually if you try!
--------------------------------------------------------------------------------------------------------
Step-1 : Obtain a Grub prompt
I have devoted a Section J to show how a Grub prompt can be obtained in the Just Booting Tips (http://www.justlinux.com/forum/showthread.php?t=144294). The last one Task J4 using a selected Live CD is possibly the easiest. You simply boot one up, press "Esc" and "c" key to get a Grub prompt.
In a Grub prompt no operating system has been booted up yet. You are talking to Grub directly and have its full attention. No middleman involved. Grub has to do everything you wish it to do. The trick is to know the commands and only a few would be enough to get by.
Step-2 : Check the partition information and find out where is your unbootable Linux.
THis command in a Grub prompt displays every partition of the 1st hard disk in the booting queue.
geometry (hd0)
Grub counts from zero so if you have more hard disk simply type "geometry (hd1)" for the 2nd disk, "geometry (hd2)" for the 3rd disk and so on.
I assume from the partition display you will be able to see where is your Linux. Since a regular Linux must have a partition Type 83 the first one you can see from your display will be most likely the unbootable Linux. This information may help you to understand various partitions
Fat16 has Type 6 or e
Fat32 has Type b or c
NTFS has Type 7
Linux has Type 83
Swap has Type 82
LVM has Type 8e
So I shall assume by reading off the partition display you can identify the first partition with type 83, say this is (hd0,3) which is the 4th partition of the 1st hard disk. In modern Linux the device name will be sda4. Older Linux may call it hda4 if it is on a Pata disk.
Step-3 : Boot up the Linux manually.
There are only 4 commands needed to boot a Linux; "root", "kernel", "initrd" and "boot".
(1) Define the root partition of the unbootable Linux (using (hd0,3) for example but do adjust it to suit your circumstance) by command
root (hd0,3)
(2) Type the "kernel" command, half-guess the kernel name starting with "/boot/vmlinuz" and let Grub to find the rest. You therefore type at a Grub prompt
kernel /boot/vmlinuzbut do not press return. Instead you hit the "tap" key. Grub will search all the files that match the front end name of "vmlinuz" in the directory of /boot inside the partition (hd0,3) . There may be several choices. Select any one (usually the one without a tail is symbolic-linked to the most recent kernel so use it) and type the full name and add "ro root=/dev/sda4" like this
kernel /boot/vmlinuz-??????????-???? ro root=/dev/sda4
This is the simplest way of booting up a Linux. The -??????????-???? is generated by Grub. You don't need to type it! See example later.
(3) Repeat Step (2) but for the "initrd" command. You hit the "tap" after finishing typing
initrd /boot/initrd
There could be several choices offered by Grub just choose one that has the same tail. Add characters to uniquely define the file name and press "tap" key again to let Grub to finish the typing. You should end up with something like this
initrd /boot/initrd-??????????-????
(4) Give the green light to Grub to fire up the Linux
boot
If you receive no objection or complaint from Grub then you should be greeted by the Linux without using its boot loader.
Conclusions
If you manage to boot up a Linux mannually without using its boot loader you open the door to the following
You can boot up most Linux this way, probably not the most optimum way but it certaily works.
You now know how to convert a Linux previously booted by Lilo to be booted by Grub. You can "cat /etc/lilo.conf" and use this information to convert the booting instructions on-the-fly.
You now know the Grub's menu.lst or grub.conf contains very instructions that you need to boot that system manually.
You should now realize that you can boot any PC system of Dos, Windows, Linux, Solaris and BSD manually if you just use chainloading.
You have just kissed all your booting problems good-bye.
--------------------------------------------------------------------------------------------------------
Examples - including all major Linux families of Ubuntu, Suse, Ferdora, Debian, Slackware and Mandriva.
The commands that I "manually" boots my Kubuntu 7.10 in a single partition sdb10 (known to Grub as (hd1,9)) in a Grub prompt are
grub> root (hd1,9)
grub> kernel /boot/vmlinuz-2.6.22-14-generic ro root=/dev/sdb10
grub> initrd /boot/initrd.img-2.6.22-14-generic
grub> bootThe green bits are generated wholly or partly by Grub via the "tap" key. The above works equally well for my Ubuntu 7.10 in sda6 (by changing to "root (hd0,5)" and "root=/dev/sda6")
My Debian 4r0 in sda11 is bootable with manual commads
grub> root (hd0,10)
grub> kernel /boot/vmlinuz-2.6.18-5-686 ro root=/dev/sda11
grub> initrd /boot/initrd.img-2.6.18-5-686
grub> boot
For my Fedora 7 in sdb6 and Mandriva in sdb10 (changing to "root (hd1,9)" & "root=/dev/sdb10"), both of which have standard vmlinuz and initrd.img names, I could fire each up with
grub> root (hd1,5)
grub> kernel /boot/vmlinuz ro root=/dev/sdb6
grub> initrd /boot/initrd.img
grub> boot
My OpenSuse 10.3 in /dev/sdb5 is a bit special and uses the swap, which is sda5 in my case, to assist it booting. After I found it out in its menu.lst I fire it up manually by adding an extra parameter resume=/dev/sda5
grub> root (hd1,4)
grub> kernel /boot/vmlinuz ro root=/dev/sdb5 resume=/dev/sda5
grub> initrd /boot/initrd.img
grub> boot
The Slackware is possibly the easiest to boot because it has no initrd and uses the standard kernel name "vmlinuz" The Slackware 12 in my sda7 was booted by
grub> root (hd0,6)
grub> kernel /boot/vmlinuz ro root=/dev/sdb7
grub> boot
--------------------------------------------------------------------------------------------------------
Complications
(A) Linux installed in multiple partitions (particularly relevant to Red Hat distros) - If you have installed the Linux in more than one partition then it is likely that the first Type 83 partition is just its /boot directory. You then need to look for the second Type 83 partition or Type 8e partition (if you use a LVM). You need to implement the follow changes to the instructions above.
(a) No need to use /boot infront of the kernel and initrd file name. For example instead of typing
kernel /boot/vmlinuzyou just need
kernel /vmlinuz
(b) You have to specify the /boot partition with the Grub's "root" command and the "/" partition with the "root=/dev/???" parameter in the kernel statement. Lets assume your /boot is (hd0,3) and the root filing system "/" of your LInux is in (hd0,5) which would be known in Linux as sda6 then you should boot your Linux with statements
grub> root (hd0,3)
grub> kernel /boot/vmlinuz-???????????? ro root=/dev/sda6
grub> initrd /boot/initrd.img-????????????
grub> boot
(B) Linux installed into a LVM - The treatment is same as (A) above except you can identify the LVM partition by Type 8e. The "root=/dev/????" parameter in the kernel statement should be pointing to the LVM partition. Linux boot loaders Grub and Lilo cannot read a LVM and so every distro using a LVM must has a separate /boot partition to store the kernel and initrd files outside the LVM for the boot loader for access.
(C) Non-standard kernel names - A handful of distros do not use the standard kernel name starting with "vmlinuz" or the initrd name starting with "initrd". Luckily they are the odd ones out. Gentoo and DSL are the two culprits. You may need to boot up a Live CD to mount its /boot to look for the kernel name. For example DSL on 2.4 kernel consistently names its kernel as "kernel24"
(D) Distros that does not have ram disk file initrd - Some distros, especially those from the Slackware and Slax families can have one large kernel and no initrd. Just omit the initrd statement in booting any of them.