GRUB2 for GRUB1 Users (201003)
These are very rough notes and unlikely to be useful to people other than me. Sorry.
In late 2009 Debian testing rolled out GRUB2. It's much more complex and more automated than GRUB1. This is probably a blessing to new users and people who've never touched GRUB as the auto-detection is better, but to those of us who have been editing the GRUB1 config for years it's a real problem. Here are my notes so far.
GRUB2's config file is
/boot/grub/grub.cfg . You should look
at this when you have problems with GRUB: but keep in mind that the message
at the top is correct. Don't edit the file, or at least if you do, realize
it will be regenerated/replaced the next time you install a kernel or run
update-grub . The "proper" way to change GRUB2's behaviour is
to edit these files:
/etc/default/grub - (as an example of the
thrash GRUB2 has seen in Debian testing, this used to be
/boot/default/grub) this includes the
basics, like the time-out and which kernel is the default.
/etc/grub.d/40_custom - adding grub kernel or
OS entries that GRUB2 doesn't auto-detect. Kernel entries are essentially
the same as GRUB1: if unsure, check the auto-detected entries in
There are several other files in
/etc/grub.d/ but these appear
to be scripts that I at least wouldn't want to modify.
I have a bootable external USB drive that I connect to one of my laptops: whenever there's a GRUB2 or kernel update, it pretty reliably toasts the MBR on the external drive. So ...
Installing the boot loader when it gets corrupted:
# mount /dev/sdb1 /mnt/tmp(note: don't use "mount /mnt/tmp" because it generally defaults to "noexec" for USB devices in /etc/fstab, which will cause major problems later)
# mount --bind /dev/ /mnt/tmp/dev
# chroot /mnt/tmp
- if you get "cannot run command /bin/bash Permission denied" or similar, it's because of "noexec": unmount (in order, including the bound /dev/), then remount by hand without noexec.
- In this chrooted environment:
# vim /etc/default/grub
# vim /etc/grub.d/40_custom
# grub-mkconfig -o /boot/grub/grub.cfg
# grub-mkconfig > /tmp/grub.cfg.newif you want to check it first
# update-grubthis does exactly the same thing, but clearly it's a bit less involved: it also over-writes
# grub-install /dev/sdbthis is the main reason you're in a chrooted environment
- If you get errors, run
grub-install --recheck /dev/sdbhaven't had to use this yet so I'm not familiar with it