Results 1 to 9 of 9

Thread: Accidentally removed all linux images

  1. #1
    Join Date
    Sep 2007
    Beans
    250

    Accidentally removed all linux images

    I accidentally removed all linux-images and now when the system restarts, I only have memcheck in the grub options.

    It is a LVM encrypted installation of Ubuntu 12.04 with my root drive on /dev/sda5 and I only have one other logical partition for swap. In other words, /usr and /boot and others are all on sda5.

    I used the Ubuntu 12.04 alternative CD to run the recovery tool. I can go as far as executing a shell under my root drive. Once there, I ran the following commands:

    Code:
    # update-initramfs -c -k all
    update-initramfs: Generating /boot/initrd.img-3.2.0-51-generic
    # update-grub
    error: unknown LVM metadata header.
    error: unknown LVM metadata header.
    Generating grub.cfg
    cat: /boot/grub/video.lst: No such file or directory
    Found linux image: /boot/vmlinuz-3.2.0-51-generic
    Found initrd image: /boot/initrd.img-3.2.0-51-generic
    error: unknown LVM metadata header.
    /usr/sbin/grub-probe: error: no such disk.
    error: unknown LVM metadata header.
    /usr/sbin/grub-probe: error: no such disk.
    error: unknown LVM metadata header.
    /usr/sbin/grub-probe: error: no such disk.
       Incorrect metadata area header checksum
    error: unknown LVM metadata header.
    done
    Any recommendations on how to fix my grub?

  2. #2
    Join Date
    Jun 2010
    Location
    London, England
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Accidentally removed all linux images

    This says that there is still one image left

    Found linux image: /boot/vmlinuz-3.2.0-51-generic

    After running update-grub, which by the way, found that image did you run?

    Code:
    sudo grub-install /dev/sda

    change to sda part to the correct hard disk that you are booting from. I do not know if this will work. I have no experience with LVM but I have found that for a change to grub.cfg to work we also need to run grub-install.

    Regards.
    It is a machine. It is more stupid than we are. It will not stop us from doing stupid things.
    Ubuntu user #33,200. Linux user #530,530


  3. #3
    Join Date
    Sep 2007
    Beans
    250

    Re: Accidentally removed all linux images

    grub-install /dev/sda1 failed with an error, which seems to be a problem with LVM headers.

    I have found https://bugs.launchpad.net/ubuntu/+s...350/comments/9 online but I'm not sure if I understand it enough to run it on my side. Basically, I need a way to fix my LVM headers.

  4. #4
    Join Date
    Sep 2007
    Beans
    250

    Re: Accidentally removed all linux images

    I made some progress. By creating a file named /boot/grub/device.map with the following content, grub-update doesn't give me errors any more:

    Code:
    (MACHINENAME-root) /dev/mapper/MACHINENAME-root
    I also updated my /etc/fstab so that the UUID for the /boot entry would be the same as what I found using vgdisplay.

    Now I will try to install grub again (I need to figure out where to install it).
    Last edited by hojjat; August 2nd, 2013 at 06:48 PM.

  5. #5
    Join Date
    Sep 2007
    Beans
    250

    Re: Accidentally removed all linux images

    Alright I made the situation worse. I did a "grub-install /dev/sda" which overwrote the whole LVM booting stuff (sorry for my uninformed language here), and now grub just gives me a disc not found error, and sends me to grub shell. There, if I do ls I only get (hd0) which means the whole LVM is not being read.

    Seems like I have broke my LVM. Does anyone know how I can restore it, or recreate it while keeping the data?

  6. #6
    Join Date
    Sep 2007
    Beans
    250

    Re: Accidentally removed all linux images

    I understand it is hard to answer my question without knowing my partition structure. Here is some more info:

    Code:
    # vgscan
      Reading all physical volumes. This make take a while...
      Found volume group "MACHINENAME" using metadata type lvm2
    # lvscan
      ACTIVE	'/dev/MACHINENAME/root' [461.60 GiB] inherit
      ACTIVE	'/dev/MACHINENAME/swap_1' [3.87 GiB] inherit
    and the root volume is the one that contains /, /usr, /boot and all the others. (So no separate volume for boot, for example).

    Also, the menuentry section of grub.cfg for 10_linux contains these lines:

    Code:
    ...
      set root='(MACHINENAME-root)'
      search --no-floppy --fs-uuid --set=root eb8090d6-e4f6-46b9-9aaa-281cdbd4206f
    ...
    That UUID is exactly the UUID that grub shows me when it fails to boot. It is NOT the same as the UUID for my logical volume though.
    Last edited by hojjat; August 2nd, 2013 at 08:20 PM.

  7. #7
    Join Date
    Sep 2007
    Beans
    250

    Re: Accidentally removed all linux images

    I realized that my /boot used to be on /dev/sda1 so I did the following:

    Code:
    mount /dev/sda1 /boot
    grub-install /dev/sda
    That took me back to the state where I opened this thread. Now I have a working grub, which only lists memeory check as the boot option (so no linux image is recognized).
    Last edited by hojjat; August 2nd, 2013 at 09:42 PM.

  8. #8
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Accidentally removed all linux images

    I think you will probably need to boot from a live CD/USB, then decrypt and mount your root lvm (installing the lvm2 package if not provided by the live environment), then chroot into it and purge and re-install grub from there

    At least that's pretty much what I had to do recently when I messed up my [non-encrypted] lvm-based install

    The boot-repair CD *may* work for you (although it didn't for me, even without the encryption) --> https://help.ubuntu.com/community/Boot-Repair

  9. #9
    Join Date
    Sep 2007
    Beans
    250

    Re: Accidentally removed all linux images

    I fixed it!

    I had to copy the existing vmlinuz and config files form the /boot directory in sda5 to sda1. Then I had to remove a few broken entries from /etc/fstab

    It took so many hours to fix, but at least I still have my data!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •