< Day Day Up > |
Recipe 12.7. Discovering Boot Parameters from the GRUB Command Shell12.7.1 ProblemYou don't know the locations of Linux kernels and root devices on your system, and you need to find them so you can boot the system. 12.7.2 SolutionUse GRUB's tab completion to find root devices and kernel images. First, boot to the GRUB command shell by hitting c when GRUB starts up. To find the root device (partition containing /boot), type root (hd0 and hit the Tab key until you see some partitions displayed: grub> root (hd0,<tab>
Possible partitions are:
Partition num: 0, Filesystem type is ext2fs, partition type 0x83
Partition num: 1, Filesystem type is ext2fs, partition type 0x83 When there are several partitions displayed, and you are not sure which one you want, it does not hurt to try them all. First, try (hd0,0): grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83 Then search for the kernel image. Type kernel /boot/vmlinuz, and hit Tab. If there is no /boot/vmlinuz, GRUB will tell you: grub> kernel /boot/vmlinuz<tab>
Error 15: File not found If this happens, reset the root device to the other partition, and look for a kernel image there: grub> root (hd0,1) Filesystem type is ext2fs, partition type 0x83 grub> kernel /boot/vmlinuz<tab> possible files are: vmlinuz vmlinuz-2.4.21 Okay, you've found a kernel. Type the path to the kernel and the root filesystem: grub> kernel /boot/vmlinuz-2.4.21 ro root=/dev/hda2 Remember, GRUB's partition numbering starts from zero, so hd0,1 = /dev/hda2. These next two steps apply only to systems that require a ramdisk to boot. Find initrd: grub> find /boot/init<tab>
grub> find /boot/initrd-2.4.22-1.img Load the initrd image: grub> initrd /boot/initrd-2.4.22-1.img Now you can boot up: grub> boot And the system should start normally. 12.7.3 DiscussionIf you are not sure that the usual kernel naming conventions were followed, have GRUB display the entire contents of /boot. Type kernel /boot/, and hit tab: grub> kernel /boot/<tab>
System.map System.map-2.4.21 System.map-2.6.3 boot grub config-2.4.21 config-2.6.3
splash.xpm.gz vmlinuz vmlinuz-2.4.21 kernel-of-truth-2.6.3 Well, it looks like we have a wackily-named 2.6 kernel, "kernel-of-truth-2.6.3." Regardless of the silly name, it should work just like its more soberly named cousins. With tab completion, you can easily search entire filesystems. This is useful for exploring unfamiliar systems, as you can start from the root: grub> root (hd0,6) grub> find /<tab> Possible files are bin dev etc lib mnt opt tmp sys var usr boot home proc sbin root cdrom floppy initrd However, this is a big security hole, as anyone with access to the GRUB command shell can read any file on the system with cat: grub> cat /root/secretpersonalstuff.txt grub> cat /etc/shadow To close this hole, see Recipe Recipe 12.14 to learn how to password-protect GRUB. GRUB will find root devices and kernels anywhere they may be. Suppose, for example, you have two IDE hard drives. The second drive has a Linux root filesystem installed on /dev/hdb5. Boot it this way: grub> root (hd1,4) grub> kernel /boot/vmlinuz-2.4.21 ro root=/dev/hdb5 grub> boot On an unfamiliar system, you can have GRUB detect all installed hard drives: grub> root (hd <tab>
Possible disks are: hd0 hd1 12.7.4 See Also
|
< Day Day Up > |