Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

GRUB does not boot my kernel automatically or display a boot menu. Why not?

My /boot/grub/grub.conf contains the following

default 0
timeout 5

root (hd0,0)
kernel /boot/3.8.13

Instead of booting, I'm given a prompt, I can then do:

> kernel /boot/3.8.13
> boot

and the kernel will start. I want this to happen automatically.

I should probably mention that the kernel fails to boot, but that is a different topic and I don't see how it could be related (I'm assuming GRUB has no way of knowing this, unless it would be something trivial like an incompatible architecture, however it is not that trivial).

I have followed the guide at http://www.gentoo.org/doc/en/grub-error-guide.xml section 11. "Grub Just Shows a Grub Prompt"

In particular I have verified that the file grub.conf exists under /boot/grub and that the menu.lst in the same directory is a symbolic link to grub.conf. I have also executed the grub-install command.

I have tried the following arguments to grub-install:

grub-install --no-floppy /dev/sda
grub-install --root-directory=/boot /dev/sda

My system has one physical HDD, /dev/sda. I have /boot on /dev/sda1 and root on /dev/sda2, which is encrypted. However I'm not even trying to make grub load some initrd yet, first things first I want GRUB to at least be able to start the kernel before I try with the initrd.

share|improve this question
    
initrd is used by the boot process in conjunction with the kernel so that a temporary early user space can be set up to handle loading kernel modules needed to load, say, soft raid kernel modules. It's possible that grub is considering the lack of an initrd line to be an error. –  antiduh Jul 2 '13 at 13:40
    
I doubt it, because the exact same thing happens when I have an initrd included in my grub.conf. This is also a valid initrd, it makes the boot process proceed further than it otherwise would, just not boot completely. –  ioctlvoid Jul 2 '13 at 13:50

1 Answer 1

The config shouldn't be too complicated. I've changed the root= to where the root will eventually come from (your encrypted drive). Boot being on a separate partition is part of the problem here.

So lets put things together with how they should end up. First, the real root will be mounted as /dev/sda2 once you can decrypt it. /dev/sda2/boot will be an empty directory where you would mount your boot partition, /dev/sda1.

Since /dev/sda1 is going to be your boot partition, it should not have a boot directory itself, otherwise once it gets mounted, you'll have /boot/boot/[grub/, 3.8.13, initrd.img, etc].

The mount table would look something like this:

  • /dev/sda2 /
  • /dev/sda1 /boot

Move your kernel to /dev/sda1/3.8.13, move your initrd.img to /dev/sda1/initrd.img, move your grub directory to /dev/sda1/grub.

Next, we want to install grub to the mbr of /dev/sda, and never the partition /dev/sda1, so our install would look something like grub-install /dev/sda. We need to tell it where to find the config files to write to the grub config tables, which is where --boot-directory should come in.

Lets assume that while you're in your live cd, fixing this thing, that you've got /dev/sda1 mounted as /boot, and your grub configs are in /boot/grub. Install would be grub-install --boot-directory=/boot /dev/sda.

If you had /dev/sda1 mounted as /mnt/fixboot while in the livecd, then the config wouldn't change and the install command would change to grub-install --boot-directory=/mnt/fixboot.

Config:

default 0
timeout 5

root (hd0,0)
kernel /3.8.13 root=/dev/sda2
initrd /initrd.img

The config may change once you figure out how to actually decrypt /dev/sda2; it'll probably end up having to be a /dev/mapper device.

share|improve this answer
    
Tried this just now, I get: "Error 15" when GRUB loads. No prompt, nothing. –  ioctlvoid Jul 2 '13 at 14:55
    
So I think we're getting confused about what path is what, when we're talking about booting the drive, and talking about modifying the drive from what I assume is a livecd since the drive itself doesn't boot. –  antiduh Jul 2 '13 at 15:57
    
I'm sorry but this makes no sense to me, move the kernel to my encrypted device (/dev/sda2)? How is GRUB even going to be able to read the kernel? Obviously the kernel must reside on the non-encrypted /boot partition (/dev/sda1). When I'm working with this I have mounted /dev/sda2 as /mnt/gentoo and /dev/sda1 as /mnt/gentoo/boot and I've chrooted to /mnt/gentoo. –  ioctlvoid Jul 2 '13 at 21:03
    
You misread me - I said that /dev/sda1 should be where your kernel etc stays, since it's your boot drive: "Move your kernel to /dev/**sda1**/3.8.13, move your initrd.img to /dev/sda1/initrd.img, move your grub directory to /dev/sda1/grub". In grub, we're marking root=/dev/sda2, since that's what your root file system will be. You still have a /boot directory - /dev/sda1's file system provides the contents of that directory. You have to remember that you have a split system - /boot is not on your root partition, and when you finally do boot, /boot will be served directly out of /dev/sda1. –  antiduh Jul 2 '13 at 21:27
    
I see at least one source of confusion, when I typed kernel /boot/3.8.13 I apparently had a symlink /boot -> / in my /dev/sda1 boot file system. For some reason I typed as if I were in my real (/dev/sda2) file system with /boot mounted there, but in fact I was just interacting with the /dev/sda1 file system. However, in short, I now have the kernel and initrd on / in /dev/sda1. I have modified the grub.conf as suggested by you and I still get just a prompt from grub. I have not run grub-install though, I'm given to understand that only lilo requires such updating. –  ioctlvoid Jul 2 '13 at 21:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.