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.

I'm running GRUB 2.00 on a Gentoo Linux system.

I compile my own kernels manually, and then I install them in /boot with make install. I have the following kernels in /boot at the moment:

# ls -1 /boot/vmlinuz*
/boot/vmlinuz-3.7.4-gentoo-5
/boot/vmlinuz-3.7.4-gentoo-first
/boot/vmlinuz-3.7.4-gentoo-fourth
/boot/vmlinuz-3.7.4-gentoo-third

Running grub2-mkconfig results in the following output:

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.7.4-gentoo-third
Found linux image: /boot/vmlinuz-3.7.4-gentoo-fourth
Found linux image: /boot/vmlinuz-3.7.4-gentoo-first
Found linux image: /boot/vmlinuz-3.7.4-gentoo-5
done

If I now read the resulting /boot/grub2/grub.cfg file, I notice that the following entries have been created:

  • A main default entry which starts vmlinuz-3.7.4-gentoo-third
  • A submenu with the all the other entries (including recovery ones), in the same order as the grub2-mkconfig command

The problem is that at boot time I'd like to load by default the fifth revision of my kernel (vmlinuz-3.7.4-gentoo-5), not the third one (vmlinuz-3.7.4-gentoo-third). I also prefer not to access the submenu for choosing the right kernel to load.

How can I change this behaviour? How can I tell GRUB that I want to run the fifth revision of my kernel by default and not the older third revision? In general, how can I change the default entry line to match the kernel I want and not a seemingly random one picked by GRUB?

I also tried putting the following lines in /etc/default/grub:

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true

This doesn't fix the problem the way I desire. But at least GRUB seems to remembers the latest kernel I booted from and automatically selects it from the submenu. It's just that I don't like to access the submenu.

share|improve this question
    
I noticed you specified -o /boot/grub2/grub.cfg as output file. Does the directory /boot/grub/ still exist? –  ott-- Feb 26 '13 at 14:01
add comment

4 Answers

Try

mkdir -p /boot/grub/backup
mv -v /boot/grub/vmlinuz-3.7.4-gentoo-{first,third,fourth} /boot/grub/backup

This moves all your unused kernels to a backup directory, now:

grub2-mkconfig -o /boot/grub/grub.cfg

This only adds choice r5 to your menu. After doing so, read this this link and then reame all the kernels in the backup directory something other than vmlinuz if you insist on keeping them

share|improve this answer
add comment

You can set the default choice by numerical value. If you set

`GRUB_DEFAULT=3` 

in /etc/default/grub
You will set the default to the gentoo-5 entry.
GRUB_DEFAULT is zero offset, so 3 will select the fourth entry as you wish.

share|improve this answer
    
I don't know why, but it seems it doesn't work. I set GRUB_DEFAULT=3 as you said, then re-run grub2-mkconfig. But at boot time the default entry is still vmlinuz-3.7.4-gentoo-third. –  Francesco Turco Jan 27 '13 at 12:54
    
Try commenting out GRUB_SAVEDEFAULT=true It shouldn't matter, but it's not needed with numerical. –  bdowning Jan 27 '13 at 14:04
    
I don't have that option in my /etc/default/grub file. –  Francesco Turco Jan 27 '13 at 15:04
add comment

you may as well use 'GRUB_DEFAULT=saved'. In this case you'd use

$ grub2-set-default -h Usage: grub2-set-default [OPTION] MENU_ENTRY Set the default boot menu entry for GRUB.

-h, --help print this message and exit -v, --version print the version information and exit --boot-directory=DIR expect GRUB images under the directory DIR/grub2 instead of the /boot/grub2 directory

MENU_ENTRY is a number, a menu item title or a menu item identifier.

or if it's only for the next boot:

$ grub2-reboot -h Usage: grub2-reboot [OPTION] MENU_ENTRY Set the default boot menu entry for GRUB, for the next boot only.

-h, --help print this message and exit -v, --version print the version information and exit --boot-directory=DIR expect GRUB images under the directory DIR/grub2 instead of the /boot/grub2 directory

MENU_ENTRY is a number, a menu item title or a menu item identifier.

share|improve this answer
add comment

I suspect that grub2-mkconfig sorts the kernels in reverse order, assuming that they primarily contain monotonically increasing version numbers. So start picking your tags to fit that convention.

share|improve this answer
add comment

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.