Sorry to hear you had to reinstall... but for future readers of this question, here is my answer.
The cause in my case:
I was messing with my boot... thought I backed it up with:
# cd /
# tar czf boot.tgz boot
Then deleted and reformatted my boot partition. Then I was going to put the files back, but there was no boot.tgz :/
# file /initrd.img /vmlinuz
/initrd.img: broken symbolic link to `/boot/initrd.img-3.2.0-23-generic'
/vmlinuz: broken symbolic link to `boot/vmlinuz-3.2.0-23-generic
So I had the same problem as you.
And the solution:
Reinstall the initramfs stuff (which generates the initramfs file in /boot; not sure which of these is the important one, so I did all, was quick):
# aptitude reinstall grub2-common grub-pc-bin grub-gfxpayload-lists grub-common
FYI to get the list of packages for my command above, I did this:
# aptitude search grub | grep -E "^i"
Reinstall the kernel stuff (which puts the kernel in /boot; this takes long; use search first to find the right package name):
# aptitude reinstall linux-image-3.2.0-23-generic
The links were no longer broken. :)
# file /initrd.img /vmlinuz
/initrd.img: symbolic link to `/boot/initrd.img-3.2.0-23-generic'
/vmlinuz: symbolic link to `boot/vmlinuz-3.2.0-23-generic'
To avoid an error "cat: /boot/grub/video.lst: No such file or directory" running update-grub, I ran grub-install. (I had to run on multiple disks since I am using raid):
Then just to be sure... update-grub again (which the reinstall grub should have also done, but didn't have video.lst, and maybe needed the kernel file or others too):
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
Then to finish up, I make sure my boot and fstab are correct:
# umount /boot
# mount -a
# ls /boot
abi-3.2.0-23-generic config-3.2.0-23-generic grub initrd.img-3.2.0-23-generic lost+found System.map-3.2.0-23-generic vmlinuz-3.2.0-23-generic
(no idea what abi-3.2.0-23-generic is. I didn't have that file before)
And generate the initramfs again just in case it generates some relevant error messages (replace filename with correct one on your system).
# mkinitramfs -o /boot/initrd.img-3.2.0-23-generic
(no output if it works)
For example, before fixing my boot and setting up my mdadm.conf file, I would get this message:
grep: /boot/config-3.2.0-23-generic: No such file or directory
W: mdadm: the array /dev/md0 with UUID 656eb2a6:21526b55:a6f1834a:d3cc95e4
W: mdadm: is currently active, but it is not listed in mdadm.conf. if
W: mdadm: it is needed for boot, then YOUR SYSTEM IS NOW UNBOOTABLE!
W: mdadm: please inspect the output of /usr/share/mdadm/mkconf, compare
W: mdadm: it to /etc/mdadm/mdadm.conf, and make the necessary changes.
After this, I tested boot, and it worked. :)
And some basic background info... which is all that is necessary to put the above solution together:
- Grub needs to install into the MBR to tell the BIOS what to boot. (created with grub-install)
- The MBR points to the grub boot code (created with grub-install) on the disk somewhere outside partitions. (in my case with GPT, this is a bios_grub partition).
- Then this boot code finds /boot to load the grub.cfg. (created with grub-mkconfig -o or update-grub which also creates other important files)
- When you select a boot option, grub is gone, replaced by the Linux kernel (vmlinuz). The kernel starts using the initramfs file (created with mkinitramfs), which I think contains some info about the system (raid, lvm, etc. with some uuids of partitions or raid/lvm volumes) and also the modules you need (ext3, ext4, lvm, raid, etc.).
- at some point it mounts the regular system and your rc.d stuff takes over
So that is why you need all those files.