3

I had a dedicated grub partition, upon trying to diagnose this problem, I decided to change the default partition to the ubuntu system.

But it didn't work, So, I booted from the live cd, formatted the old boot partition and did a fresh install of grub, I did copy grub.cfg thinking it would be enough to boot the system.

But I was wrong, Now I am grub menu, that shows up, but what i didn't know was vmlinuz and intrd.img is also needed to boot a system.

Which is no where? How can I get out of this stupid trouble

Starx
  • 5,263
  • I tried everything, but couldn't recover from this. So, I did a clean re-install of ubuntu. – Starx Apr 17 '12 at 07:36

2 Answers2

6

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):

grub-install /dev/sda
grub-install /dev/sdb
...

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):

# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-23-generic
Found initrd image: /boot/initrd.img-3.2.0-23-generic
done

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.

Peter
  • 437
  • 1
    Just wanted to say thanks - I followed the guide as detailed above and the system now works. I had a few errors (like no aptitude lock file being an issue - so I had to manually create /run/lock after I used chroot on the partition). Thanks again –  Jun 12 '12 at 17:20
0

If what you say is true then rebuilding your system may be more trouble than it's worth. You could try re installing the kernel, which should also update grub on disk, but since you overwrote the old grub.cfg that might not even work. To get started you'll need to chroot your disk from the live installer and then apt-get install --reinstall whatever kernel version you had last. The rest is really up to you, that's quite a mess you've made for yourself. You could take it as an opportunity to learn more about how the distro boots and repair it, or you could back up your data and start over. Good luck.

ppetraki
  • 5,483