# Kernel lines in grub.conf don't appear in grub

## MALDATA

I have an odd problem. I was running kernel 3.0.6 and got the 3.1.6 update to gentoo-sources through portage. I compiled and installed 3.1.6 as usual, and added the kernel lines to the top of grub.conf, so 3.1.6 should have become the default on the next reboot.

I then pretty much just forgot about it, because I assumed on my next reboot it'd boot 3.1.6 as expected. That was about a week ago, and I just noticed now that for some reason it's still booting 3.0.6. I actually paid attention the next time I booted, and 3.1.6 is not even an option on the grub boot menu. It almost seems like grub isn't using grub.conf at all.

I also tried booting 3.1.6 by manually editing the kernel line in grub, changing 3.0.6 to 3.1.6, and it said it couldn't find the file... for your reference, here's my /boot directory and my grub.conf. Any ideas?

```

$ ls /boot

System.map-2.6.39-gentoo-r3      config-2.6.39-gentoo-r3      lost+found

System.map-2.6.39-gentoo-r3.old  config-2.6.39-gentoo-r3.old  vmlinuz-2.6.39-gentoo-r3

System.map-3.0.6-gentoo          config-3.0.6-gentoo          vmlinuz-2.6.39-gentoo-r3.old

System.map-3.1.6-gentoo          config-3.1.6-gentoo          vmlinuz-3.0.6-gentoo

System.map-3.1.6-gentoo.old      config-3.1.6-gentoo.old      vmlinuz-3.1.6-gentoo

boot                             grub                         vmlinuz-3.1.6-gentoo.old

```

```

$ cat /boot/grub/grub.conf

# This is a sample grub.conf for use with Genkernel, per the Gentoo handbook

# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2

# If you are not using Genkernel and you need help creating this file, you

# should consult the handbook. Alternatively, consult the grub.conf.sample that

# is included with the Grub documentation.

# default starts indexing at 0

default 0

timeout 5

#splashimage=(hd0,0)/boot/grub/splash.xpm.gz

#title Gentoo Linux 2.6.30a

#root (hd0,1)

#kernel /boot/kernel-2.6.30a real_root=/dev/md3

#initrd /boot/initramfs-genkernel-x86-2.6.24-gentoo-r5

title Gentoo Linux 3.1.6-gentoo

root (hd0,1)

kernel /boot/vmlinuz-3.1.6-gentoo real_root=/dev/md3 ramdisk_size=128000

title Gentoo Linux 3.0.6-gentoo

root (hd0,1)

kernel /boot/vmlinuz-3.0.6-gentoo real_root=/dev/md3 ramdisk_size=128000

title Gentoo Linux 2.6.39-gentoo-r3

root (hd0,1)

kernel /boot/vmlinuz-2.6.39-gentoo-r3 real_root=/dev/md3 ramdisk_size=128000

title Windows XP Pro

rootnoverify (hd0,0)

makeactive

chainloader +1

# vim:ft=conf:

```

----------

## Jaglover

Things like that happen when you forget to mount /boot. Try running ls on /boot when mounted and when umounted. If you see anything on umounted /boot ...

----------

## MALDATA

Thanks, Jaglover, but that didn't seem to be the problem here. I always have /boot mounted. I gave it a try anyway though... after unmounting /boot, I went in there and there weren't any files.

Other ideas?

----------

## dwbowyer

could we see 

```

ls -l /boot

```

edit and

```

ls -l /usr/src

```

I'm thinking you may have copied a 3.0.6 built kernel to /boot with 3.1.6 name,. but uname -r should ought still report the internal version.

----------

## MALDATA

Sure thing.

```

$ ls -l /boot 

total 35330

-rw-r--r-- 1 root root 2391935 Sep 20 18:51 System.map-2.6.39-gentoo-r3

-rw-r--r-- 1 root root 2391572 Jul 21 22:40 System.map-2.6.39-gentoo-r3.old

-rw-r--r-- 1 root root 2539064 Dec  1 21:55 System.map-3.0.6-gentoo

-rw-r--r-- 1 root root 2593916 Jan 19 19:04 System.map-3.1.6-gentoo

-rw-r--r-- 1 root root 2593916 Jan  8 22:44 System.map-3.1.6-gentoo.old

lrwxrwxrwx 1 root root       1 Jun 25  2009 boot -> .

-rw-r--r-- 1 root root   87790 Sep 20 18:51 config-2.6.39-gentoo-r3

-rw-r--r-- 1 root root   85912 Jul 21 22:40 config-2.6.39-gentoo-r3.old

-rw-r--r-- 1 root root   88570 Dec  1 21:55 config-3.0.6-gentoo

-rw-r--r-- 1 root root   89989 Jan 19 19:04 config-3.1.6-gentoo

-rw-r--r-- 1 root root   89989 Jan  8 22:44 config-3.1.6-gentoo.old

drwxr-xr-x 2 root root    1024 Jan  8 22:44 grub

drwx------ 2 root root   12288 Jun 25  2009 lost+found

-rw-r--r-- 1 root root 4554576 Sep 20 18:51 vmlinuz-2.6.39-gentoo-r3

-rw-r--r-- 1 root root 4552976 Jul 21 22:40 vmlinuz-2.6.39-gentoo-r3.old

-rw-r--r-- 1 root root 4613664 Dec  1 21:55 vmlinuz-3.0.6-gentoo

-rw-r--r-- 1 root root 4662752 Jan 19 19:04 vmlinuz-3.1.6-gentoo

-rw-r--r-- 1 root root 4662752 Jan  8 22:44 vmlinuz-3.1.6-gentoo.old

```

```

$ ls -l /usr/src 

total 78996

lrwxrwxrwx  1 root root       18 Jan  8 22:24 linux -> linux-3.1.6-gentoo

drwxr-xr-x 20 root root     4096 Dec 12 20:23 linux-2.6.39-gentoo-r3

drwxrwxr-x 23 root root     4096 Aug 29 15:56 linux-3.0.4

-rw-r--r--  1 root root 76759291 Sep 18 22:14 linux-3.0.4.tar.bz2

drwxr-xr-x 24 root root     4096 Dec 13 19:02 linux-3.0.6-gentoo

drwxr-xr-x 24 root root     4096 Jan 19 19:04 linux-3.1.6-gentoo

drwxr-xr-x  6 root root     4096 Sep  1  2010 v4l-dvb-a4c762698bcb

-rw-r--r--  1 root root  4019180 Sep  1  2010 v4l-dvb-a4c762698bcb.tar.bz2

lrwxrwxrwx  1 root root       28 Oct  3 22:50 vboxhost-4.1.4 -> /opt/VirtualBox/src/vboxhost

```

And just for good measure,

```

$ uname -r

3.0.6-gentoo

```

----------

## dwbowyer

To test on my system I did added the following on my system

```

title JustATest 

root (hd0,0)

kernel /boot/4.0.9-gentoo root=/dev/sda3 vga=0x318

```

With no such kernel file on the partition, the menu entry still shows up in the grub menu. Attempting to boot from it produces

```

Error 15: File Not Found

```

Which is what I'd expect. The fact that you do NOT see the menu entry suggests that something is wrong in the /boot/grub/grub.conf

itself, possibly to do with whitespace characters. I suggest deleting those lines, and the preceding and following EOL (end-of-line) characters.

Just to be clear, I mean everything between the red asterisks, below. Then re-create those lines and save the grub.conf. Reboot and see if the

entry shows up.

 *Quote:*   

> 
> 
> #initrd /boot/initramfs-genkernel-x86-2.6.24-gentoo-r5*
> 
> title Gentoo Linux 3.1.6-gentoo
> ...

 

 *MALDATA wrote:*   

> 
> 
> I also tried booting 3.1.6 by manually editing the kernel line in grub, changing 3.0.6 to 3.1.6, and it said it couldn't find the file...
> 
> 

 

That itself should have worked. But whether 1: the file exists, 2: is a valid uncorrupted kernel file

are possibly separate issues from 3: shows up as a grub menu entry. One thing at a time.

----------

## MALDATA

Removed and rewrote those lines in my grub.conf... no difference at all.

I'm completely baffled...

----------

## dwbowyer

You could use my JustATest example above just to verify that it shows up in the grub menu. That rules out any oddity about grub.conf. 

EDIT just change the root  (hd0, 1) or that will be it's own problem,

----------

## cld71

 *MALDATA wrote:*   

> Removed and rewrote those lines in my grub.conf... no difference at all.
> 
> I'm completely baffled...

 

This is a long shot, but have you checked that your "/boot/grub/menu.lst" file is a link to your grub.conf like this "menu.lst -> grub.conf" when doing an "ls -la" on /boot/grub directory?

----------

## MALDATA

dwbowyer: I'll give it a shot when I get home and let you know.

cld71: Yeah, I checked that. The link is there and it's valid.

Thanks, and keep the suggestions coming.

----------

## Jaglover

Have you tried running grub-install again?

----------

## eccerr0r

Not 100% sure if this is the same issue but one thing I ran into with grub is installing grub on the wrong partition so the grub.conf it's looking for is never in the right place.

You want to install grub on the MBR and have it point to stage1,stage2, etc. on the right partition.

I'd suggest people not use a /boot parition when first trying installing grub unless absolutely needed - usually only if your BIOS can't access your whole disk.  In any case I've found that grub-install does automagically do the right thing as long as the correct disks are mounted in the right place.

If you grub-install to your /boot partition directly (like /dev/sda2), then it will think things should be rooted in that disk.  Your menu.lst (which is the proper grub config file - a symlink makes it grub.conf) would expect to be in that disk's boot/grub directory.  Sounds right?  No, after you mount that partition to /boot, the config file is /boot/boot/grub/menu.lst instead... ouch.

I still have a lot of disks that have screwed up partitions and don't want to touch them since they're working... once they break I'll fix them after finding the correct solution...

----------

## Logicien

Hi,

in Grub version one, the grub-install command copy things in /boot/grub and than install the boot loader where it have been specified. If you only write

```
grub-install /dev/sda
```

Grub will assume the root for it is the root partition of Gentoo, so here /dev/sda3. In reality Grub root shoud be /dev/sda2, because you have a /boot/partition. If this partition is always mounted, everythings should be in. So using the Grub shell I would do

```
grub> setup (hd0) (hd0,1)
```

to tell Grub to install to the MBR and use /dev/sda2 as the partition for it to find it's files. That procedure probably could be done with the grub-install command to. The /boot directory should be empty or with only a .keep file before the boot partition is mounted in by Gentoo.

----------

## MALDATA

I'm not sure I understand. Everything's been working fine with this installation for a couple years now. Why would any of this start causing a problem now?

----------

## Jaglover

I'm not sure I understand your response, did you try re-running grub-install or not? Doing so cannot harm your Gentoo but it may resolve your problem.

----------

## Logicien

So, your installation of Grub one date from years now. Grub one have probably been updated since then. Reinstall Grub in the MBR with

```
grub-install /dev/sda
```

will copy again the files from /usr/lib/grub/*/* to /boot/grub and install it's bootloader in the MBR. With that, you will be sure all the files it use are up to date. In plus I would reinstall again the Grub bootloader with the Grub shell commands

```
grub

...

grub> setup (hd0) (hd0,1)

grub> exit
```

Everythings will be clear an up to date. If the problem persist, we will know it is not coming from Grub installation.

You have a boot symlink to /boot in the /boot directory. Me with ArchLinux, I use only /boot/grub/menu.lst as the configfile for Grub one. You have'nt show the contain of /boot/grub. A symlink from grub.conf to menu.lst in that directory can be usefull. Better can be to copy grub.conf to menu.lst. I ever read that Grub do not like symlink. Your grub.conf look good. There is a command call grub-set-default you can use to set the default boot entry in Grub one. Something have to be done to resolv this problem.

I use mainly Grub two now.

----------

## derk

um If you have two root partitions .. i.e. sda1 and sda2  and kernels installed on both corresponding boot directories  (works with a separate boot as well)

this works:

title sam0 Gentoo Linux 3.2.1

root (hd0,0)

kernel (hd0,0)/boot/vmlinuz-3.2.1-gentoo root=/dev/sda1 

title sam1 Gentoo Linux 3.2.1

root (hd0,1)

kernel (hd0,1)/boot/vmlinuz-3.2.1-gentoo root=/dev/sda2

----------

## dwbowyer

Not sure it's worth mentioning but I just read in 3.0.6 menuconfig while doing something else that the ramdisk_size option is obsolete. Perhaps try removing the opt?

----------

## MALDATA

Jaglover:

 *Quote:*   

> did you try re-running grub-install or not?

 

Yep, still the same issue.

Logicien:

 *Quote:*   

> You have'nt show the contain of /boot/grub

 

Here it is:

```

$ ls -al /boot/grub/

total 448

drwxr-xr-x 2 root root   1024 Jan 20 20:48 .

drwxr-xr-x 4 root root   1024 Jan 19 19:04 ..

-rw-r--r-- 1 root root    197 Jun 25  2009 default

-rw-r--r-- 1 root root     60 Jun 25  2009 device.map

-rw-r--r-- 1 root root   8756 Aug  1  2010 e2fs_stage1_5

-rw-r--r-- 1 root root   7836 Aug  1  2010 fat_stage1_5

-rw-r--r-- 1 root root   7112 Aug  1  2010 ffs_stage1_5

-rw-r--r-- 1 root root   1050 Jan 20 20:48 grub.conf

-rw-r--r-- 1 root root   1050 Jan 19 22:32 grub.conf~

-rw-r--r-- 1 root root   7104 Aug  1  2010 iso9660_stage1_5

-rw-r--r-- 1 root root   8692 Aug  1  2010 jfs_stage1_5

lrwxrwxrwx 1 root root      9 Jun 25  2009 menu.lst -> grub.conf

-rw-r--r-- 1 root root   7328 Aug  1  2010 minix_stage1_5

-rw-r--r-- 1 root root   9732 Aug  1  2010 reiserfs_stage1_5

-rw-r--r-- 1 root root  33856 Aug  1  2010 splash.xpm.gz

-rw-r--r-- 1 root root    512 Aug  1  2010 stage1

-rw-r--r-- 1 root root 107988 Aug  1  2010 stage2

-rw-r--r-- 1 root root 107892 Jun 25  2009 stage2.old

-rw-r--r-- 1 root root 107988 Aug  1  2010 stage2_eltorito

-rw-r--r-- 1 root root   7368 Aug  1  2010 ufs2_stage1_5

-rw-r--r-- 1 root root   6712 Aug  1  2010 vstafs_stage1_5

-rw-r--r-- 1 root root   9532 Aug  1  2010 xfs_stage1_5

```

dwbowyer:

 *Quote:*   

> Not sure it's worth mentioning but I just read in 3.0.6 menuconfig while doing something else that the ramdisk_size option is obsolete. Perhaps try removing the opt?

 

Tried it, still no luck.

Thanks again for the help, everyone. Tried a few other things too, but nothing's working. Where to from here?

----------

## Logicien

Did you execute the Grub shell commands

```
grub

...

grub> setup (hd0) (hd0,1)

...

grub> exit
```

----------

## MALDATA

Logicien

 *Quote:*   

> Did you execute the Grub shell commands

 

Yes I did.

----------

## Knute

Just a quick question....  Are you using grub or grub-static???

grub is actually grub2, and an update may have auto-migrated you over to grub2.

If you have a /boot/grub2 directory, then odds are you are using grub2, where the grub1 config files don't work.

If you have that directory try running the command: grub2-mkconfig -o /boot/grub2/grub.cfg as root.

This command will update your configs so that it should show up.  (I have simply made it a script file with executable file permission and root ownership in /sbin)

HTH

----------

## Knute

Just a quick question....  Are you using grub or grub-static???

grub is actually grub2, and an update may have auto-migrated you over to grub2.

If you have a /boot/grub2 directory, then odds are you are using grub2, where the grub1 config files don't work.

If you have that directory try running the command: grub2-mkconfig -o /boot/grub2/grub.cfg as root.

This command will update your configs so that it should show up.  (I have simply made it a script file with executable file permission and root ownership in /sbin)

HTH

----------

## MALDATA

I'm using grub

```

*  sys-boot/grub

      Latest version available: 0.97-r10

      Latest version installed: 0.97-r10

      Size of files: 1,036 kB

      Homepage:      http://www.gnu.org/software/grub/

      Description:   GNU GRUB Legacy boot loader

      License:       GPL-2

*  sys-boot/grub-static

      Latest version available: 0.97-r10

      Latest version installed: [ Not Installed ]

      Size of files: 868 kB

      Homepage:      http://www.gnu.org/software/grub/

      Description:   GNU GRUB Legacy boot loader (static build)

      License:       GPL-2

```

But it doesn't appear to be grub2. I do not have a /boot/grub2 directory.

----------

## Logicien

Have you try to umount the boot partition (umount /boot) and see what is the contain of the /boot directory (ls -a /boot) when nothing is mounted in? You use, if I understand, RAID (/dev/md3). That can change the way Grub see the partitions table. I never had to use LVM and RAID. I cannot help for that. I have to study first.

I think it not to early to switch to Grub two even if it is unstable and masked according to Portage. I use it since a while with others Linux distributions. It work fine when you understand the version. Grub one stay easier but, with less features.

----------

## MALDATA

 *Quote:*   

> Have you try to umount the boot partition (umount /boot) and see what is the contain of the /boot directory (ls -a /boot) when nothing is mounted in?

 

Yep. In fact, that was Jaglover's first reply also. I gave it a try, but there's nothing in /boot when it's not mounted.

----------

## MALDATA

I tried a couple simple things... my grub menu has a listing for Windows, so in /boot I did a grep for that to see if maybe there were multiple files in there that grub might be looking at.

```
# grep -r Windows *

grep: warning: boot/boot: recursive directory loop

boot/grub/grub.conf:title Windows XP Pro

boot/grub/menu.lst:title Windows XP Pro

grub/grub.conf:title Windows XP Pro

grub/menu.lst:title Windows XP Pro

```

Since boot is a symlink to ./ and grub/menu.lst is a symlink to grub.conf, all these things in the list are the same file. By the way, those symlinks were made by the system, I didn't set it up that way.

Anyway, if I change the name in the Windows title line to something else, the change is not shown in the grub menu on a reboot. So, grub has to be getting its information from a different file. Anyone know if there's a way to ask grub which file it's reading?

----------

## dwbowyer

MALDATA: Thinking about your LAST post, I am wondering, is there ANY possibility that you have another /boot partition, such as say a separate Ubuntu install on any drive in the PC? Could it be that the system boots from a different grub installation than the Gentoo one and thus you would have another /boot/grub/grub.conf that is being read?

----------

## MALDATA

Hi all,

I figured out what happened. My /boot partition is a software raid1. But when I took a look at cat /proc/mdstat, only one of the two drives was there. It wasn't that one device had failed... it just wasn't there at all. I have no idea what happened. So I had to do

```

# mdadm --add /dev/md1 /dev/sda2

```

to add the other drive back in, it synced them, and then all of a sudden, everything was cool.

So I guess my only question now is why would a drive just get booted out of a raid array? And is there something I should have been doing to keep an eye on it?

----------

