A little while ago I wrote about my problems booting Linux on a Dell Optiplex 320 the solution was to install Grub 2 and tweak the boot options. Since then I have run into a couple other problems which have required me to learn a little more about managing Grub 2 on a Debian based system (Ubuntu in my case). Specifically, I want my changes to grub.cfg to persist between kernel upgrades. So here is what I have learned.
Background
Every time a new kernel is installed, /usr/sbin/update-grub is called. This re-writes /boot/grub/grub.cfg. So any changes you make to grub.cfg directly are obliterated. However, the new grub.cfg is generated from:
- /boot/grub/grub.cfg
- /etc/grub.d
So if I know how to edit those files, I can make my changes persistent.
Changing default kernel options
/etc/default/grub allows you to set parameters that appear in the grub.cfg file. In my case I wanted every “linux” command to have the “acpi=off” option appended. So I added the following line to /etc/default/grub:
GRUB_CMDLINE_LINUX=acpi=off
Now just run
sudo /usr/sbin/update-grub
and presto! All the “linux” commands have acpi=off appended.
Adding a boot option
My other problem was that everytime grub.cfg was updated, my Windows boot option was deleted. To fix that I needed to add a new file to /etc/grub.d. Read /etc/grub.d/README for more details, but the summary is:
- Create a file named “21_windows”
- Put the following code in the file:
#!/bin/bash
set -e
cat << EOF
menuentry "Other Operating Systems" {
set root=(hd0,1)
title Other Operating Systems
}menuentry "Microsoft Windows XP Professional" {
set root=(hd0,1)
chainloader +1
boot
}
EOF - Make the file executable:
sudo chmod 755 /etc/grub.d/21_windows
- Re-run
sudo /usr/sbin/update-grub
That is all, hope it helps.
Just wanted to say thanks for the concise how-to I was pulling my hair out after a new install trying to find menu.lst. Thanks a bunch!
You are welcome. Thank you for letting me know it was a help. It is encouraging to know that my posts help someone out.