posted by steve | Category: Useful Items That I Forget |
One question I’ve seen in a few forums is how to change the default boot order of operating systems when using Linux (Debian, Ubuntu, Red Hat, others) and more specifically when using either the GRUB boot loader or LILO. There are of course various reasons for doing so such as making a different kernel boot by default or making Windows boot first, and so on.
Since I tend to compile my own kernel, I find that I work closely with both boot loaders, depending on the Linux flavor installed.
Note: The methods described herein are ones that I’ve used. Use caution if you choose to use them in your set ups. Because you’re working with boot loaders, you can make it so that the computer won’t boot, potentially losing all of your data and whatever else that may bring. I wouldn’t recommend using anything here on your computer. If you mess up or misinterpret my notes here, you might break your rig.
Grub
To change the boot loader order in GRUB you need to edit menu.lst. The location of that file is usually /boot/grub/menu.lst, but it might be elsewhere, maybe in the /etc hierarchy. If it’s not at /boot/grub/menu.lst (that’s where you’d find it on Debian Etch), then do this to find it:
find / -name "menu.lst"
Edit menu.lst in your favorite editor. A simple editor to use is nano (run: apt-get install nano). I personally use Vim. Within menu.lst, you’ll see a section like this, though the content may vary:
title Debian GNU/Linux, kernel 2.6.22.1
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro
savedefault
title Debian GNU/Linux, kernel 2.6.22.1 (single-user mode)
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro single
savedefault
title Debian GNU/Linux, kernel 2.6.16.7
root (hd0,0)
kernel /vmlinuz-2.6.16.7 root=/dev/sda3 ro
savedefault
Essentially, with that configuration of menu.lst, the first section will be the kernel/OS that loads. Therefore, to change the order, move kernel/OS choice to the top. So, for example, if I wanted kernel 2.6.16.7 to load by default, I’d move its section to the top and the code would then look like this:
title Debian GNU/Linux, kernel 2.6.16.7
root (hd0,0)
kernel /vmlinuz-2.6.16.7 root=/dev/sda3 ro
savedefault
title Debian GNU/Linux, kernel 2.6.22.1
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro
savedefault
title Debian GNU/Linux, kernel 2.6.22.1 (single-user mode)
root (hd0,0)
kernel /vmlinuz-2.6.22.1 root=/dev/sda3 ro single
savedefault
That’s all there is to it. Save menu.lst of course.
LILO
Like Grub, lilo also has a configuration file that controls the boot options. Lilo’s config file is usually found at /etc/lilo.conf. Edit this file in your editor of choice.
Within that file, usually towards the bottom, you’ll have some sections like this:
image=/vmlinuz
label=Linux
read-only
initrd=/initrd.img
image=/vmlinuz.old
label=LinuxOLD
read-only
optional
initrd=/initrd.img.old
other=/dev/hda3
label=windows
Usually above those definitions you’ll see something like this:
default=Linux
The name after the equals sign, “Linux” in the example above, corresponds to the label option within the image/definition stanza. Therefore, to change the default operating system to say, LinuxOLD from the example, you’d simple change the default line like this:
default=LinuxOLD
For most installations that dual boot or multi-boot Linux and Windows, the label might be simply “windows”. Therefore, the line would be:
default=windows (though obviously this depends on the label of the actual windows stanza so use with caution.)
Once you save lilo.conf it’s important that you run the lilo command. Simply typing lilo at the command prompt should run it just fine (as root). If you forget to run the lilo command after editing the lilo configuration file then the changes won’t take effect and you’ll be left wondering why it didn’t work. Trust me, I’ve been there as have countless others. Run lilo after making changes to lilo.conf.
Leave a Reply
Archives
- February 2012
- January 2012
- December 2011
- November 2011
- July 2011
- June 2011
- February 2011
- September 2010
- December 2009
- November 2009
- September 2008
- August 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- March 2007
- December 2006
- August 2006
- July 2006
- December 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- March 2005
- February 2005
- December 2004
- October 2004
- September 2004
- July 2004
Categories