06/18: grub update broke boot
I run Debian Sid on my laptop. Sid is the unstable or “Still in development” release of Debian. Just recently (on Jun 14, likely) grub was updated in a way that broke my boot. The symptom was that my laptop passed the BIOS, but printed something like “unaligned pointer 0x4c19a146” and then stopped. No grub menu, no graphics, no console, nothing. And of course, no response when you type stuff.
The (short-term, non-participative) solution is to downgrade grub until the problem is fixed. I got a question as to how to do the downgrade when your system won’t boot. So ….
First you find a CD that you can boot from. I used the Debian netinst CD. I had an iso image lying around for Debian 5.02, but pretty much any live CD that lets you have a shell will do. Stick the CD in the machine and reboot. If necessary, change the BIOS settings to boot from the CD first (not the hard disk).
The Debian netinst CD wants to do an install. Press Ctl-Alt-F2 to get another console, and press enter to get a prompt.
If you have one of those fancy-pantsy live CD’s that mounts your disks for you, you might have to unmount them first. At least you’ll know what the names are, in that case …
umount /dev/sda1 umount /dev/sda5 umount /dev/sda6 umount /dev/sda7 umount /dev/sda8
Now you want to mount your hard disks onto the running system and chroot to the root of the hard disk hierarchy. In my case, I have several partitions. I can never remember what the partitions are called — are they hda, hdb, sda, sdb or something else? So I look for disk-related entries in the output from dmesg:
dmesg | egrep '[sh]d'
or
dmesg | grep disk
or even
dmesg | grep '<'
Don’t forget to quote the angle-bracket on that last one.
It turns out my partitions are:
/dev/sda1 /boot /dev/sda2 / /dev/sda5 /usr /dev/sda6 /var /dev/sda7 /home /dev/sda8 /srv
So I created a directory /mnt/target, and mounted the partitions:
mount -t ext3 /dev/sda2 /mnt/target mount -t ext3 /dev/sda1 /mnt/target/boot mount -t ext3 /dev/sda5 /mnt/target/usr mount -t ext3 /dev/sda6 /mnt/target/var mount -t ext3 /dev/sda7 /mnt/target/home mount -t ext3 /dev/sda8 /mnt/target/srv
Then chrooted to the top of the disk hierarchy:
cd /mnt/target chroot .
Then mount the proc partition (needed for dpkg later)
mount -t proc proc /proc
I looked in the logs to see what version was broken and what version it replaced. Looked in /var/log/dpkg.log … found that grub-pc_1.98-20100614-2 was the one that had just been installed and it was replacing grub-pc_1.98-20100602-1 which used to work just fine. I have been running apt-cacher on the laptop, and looked in the cache to see if the old package was still there — it was.
Then I was able to run dpkg to install the older version of grub. I found it with
ls /var/cache/apt-cacher/packages/*grub*
because that directory has a _lot_ of files in it and I was only interested in grub packages.
grub-pc depends on grub-common so I installed them both:
cd /var/cache/apt-cacher/packages dpkg -i grub-pc_1.98-20100602-1-686.deb grub-common_1.98-20100602-1-686.deb
That command took care of the grub-install command for me ….
Then I rebooted and when it came up again, I saw a nice grub, and grub started up Linux and all was good. This way of rebooting will unmount the disk partitions nicely. It doesn’t matter that the netinst disk thinks you’re still in the middle of an install.
shutdown -r now
The last step is to tell dpkg and apt and the whole package management chain not to ever install a different grub version. Edit /etc/apt/preferences to contain:
Package: grub-pc Pin: version 1.98-20100602-1-686 Pin-Priority: 1001 Package: grub-common Pin: version 1.98-20100602-1-686 Pin-Priority: 1001
You’ll have to remember to change that at some time in the future so you’ll get grub updates. Personally, I’m not in a rush for that.
Note that I wrote this mostly from memory so paths and version numbers might not be exactly correct. Keep your eyes open, if you’re following these instructions!