Changing the Default Boot with Ubuntu 9.10 GRUB 2
Posted by: J.A. Watson
on November 09 2009
I have been struggling recently with Ubuntu 9.10, using GRUB 2, trying to do something which was more or less trivial with previous releases. What I would like to do is set up a multi-boot system for a friend with Ubuntu and Windows, and have it boot Windows by default. Simple, right? Not so far, at least for me.
I know what needs to be done, the "default" value needs to be changed from "0" to whatever the appropriate entry number is in /boot/grub/grub.cfg. But I also know that one shouldn't edit grub.cfg (if I read that one more time, in one more different place, I'm going to scream), so it has to be changed in /etc/grub.d/00_header. But the problem is that the content of grub.cfg sometimes change in such a way as to change the number of boot entries!
Here's an example which illustrates the problem. Assuming a simple multi-boot system with Windows installed in the first partition, and Ubuntu 9.10 in the second, the grub.cfg file is initially created with two boot entries for the linux kernel (normal and recovery mode), two boot entries for memtest (graphic console and serial console), and then the boot entry for Windows (chainloader). So the correct default value would be 4 to boot Windows.
However, when a kernel update is installed, and a new kernel is compiled - say from 2.6.31-14 to 2.6.31-15 - the old kernel is left in place, and when grub.cfg is recreated, there are two boot entries for that kernel added between the (new) current kernel and memtest! This means that the Windows boot has suddenly become entry number 6 instead of 4. Uh-oh.
I believe that the situation becomes even more confusing with subsequent updates, because it looks like the scripts at least attempt to clean up old kernels in /boot, but I'm not clear on how and when this happens, how aggressive it will be, whether there will ever be more than one previous kernel version present, or whether it will ever "clean up" so much that there is once again no previous kernel present at all.
Perhaps I am overlooking something obvious, because I can't imagine that it was intended to be this difficult to set a default boot other than the latest Linux kernal, was it? I have to go back and read the /etc/grub.d scripts carefully again, and watch how the kernels and grub.cfg evolve over time.
jw 10/11/2009

written by kunthar, November 12, 2009
It should be /boot/grub/grub.cfg
The rest of the procedure is correct.
Your point is different. You say, there is a problem whenever kernel order changed in Grub.
But the method to change default kernel is like this. We are looking different problems and solutions.
Any way hope it helps someone as me, coming to this blog by searching google wastebin.
written by avid, November 15, 2009
Jumping into "10_linux", what it does is check the contents of /boot/ and / for files matching vmlinu[xz], then sorts and processes them [writes out to grub.cfg] in descending order. So it seems reasonable that any new kernel updates would be normally prepended to the boot list. Continuing further down grub.cfg, the memtest menu entires are generated by "20_memtest" and finally your Windows entries are by "30_os-prober".
The menu order would always look something like:
1. Linux kernels for your active distro (newest listed first)
2. Memtest
3. Anything else (e.g. windows, other linux distros)
It seems that the system was designed around presenting a logical menu ordering first and in the process of doing so, alienate most grub users familiar with grub "Default" by making the behavior of the new "GRUB_DEFAULT" unintuitive.
Regarding your problem, since "GRUB_DEFAULT" has no real weight in determining a default other than something like 'latest kernel (0)' or 'second latest kernel (1), etc, you will have to look into changing the ordering of execution of the scripts creating grub.cfg. Fortunately, I discovered that this can be done easily by renaming '30_os-prober" to something like "09_os-prober". The result is that update-grub will process it before "10_linux" and inserts these menu items on top of the heap. I can't test this definitely though as I don't currently have anything else installed.
I hope this helps! I certainly learned more about grub2!
written by digitalpbk, November 16, 2009
http://digitalpbk.com/2009/11/...ubuntu-910
written by kunthar, November 17, 2009
We are not all nature English speakers. We are searching the internet and finding the results. I found this blog while searched about grub2 boot problem. Sure, here is not an exact place to put those comments on. But it works. It seems so many people comes to this blog exactly with same purposes as me. Because this site is indexing more frequently then mine by Google. And you see someone made a blog as well as me. Mine is here too.
http://www.kunthar.com/blogs/kunthar.php/grub2-switching-boot-order
The nature of semantic internet connections couldn't be classified easily. I respect your problem but the things on the internet are not always crystal clear. Hope i could express myself.
written by vasya, November 17, 2009
for example:
# GRUB_DEFAULT="xxxx" - An exact menu entry, including the quotation symbols, may also be used. In this case, location in the menu will not matter. Example: GRUB_DEFAULT="Windows 7 (loader) on /dev/sda1"
see
http://ubuntuforums.org/showthread.php?t=1195275
for more



1. cat /etc/group/group.cfg
see the order of the wanted kernel. Starts from 0.
2. vi /etc/default/grub
change GRUB_DEFAULT=0 value to wanted kernel
3. run update-grub to update
4. reboot and check with uname -r to see if correct kernel selected.
My last word is, i never like grub guys. You're doing something wrong guys. This shouldn't be such a complicated as this. Your way is WRONG!