Ubuntu – Accidentally deleted “linux-image-generic” – how to recover

bootkernelpackage-management

Well I tell you that my problem started when upgrading to Ubuntu 11.04. As it happened to me when I updated Ubuntu 10.04 to 10.10, every time I installed something, I got an error when reading "linux-image-generic". That time I solved it by installing a software, called Ubuntu Tweak, with which I deleted all temporary files and old installation packages, and I don't know very well why, but it worked and the problem stopped.

This time I tried to do otherwise, and follow the steps that they said in this thread:

initramfs problem when out of disk space

Well, I purged those files and after restarting it tells me:

ERROR 15: FILE NOT FOUND
Press any key to continue ...

And that gives me to choose between:

10.04.1 Ubuntu LTS, Karel-24-generic 06/02/1932

10.04.1 Ubuntu LTS, Karel 06.02.1932-24-generic (Recovered)

Any of which leads me back to the Error 15 again.

I started from my old Windows partition and using Ext2fsd to read the Linux partition, I could retrieve the file where I had copied the error log that I had when updating. I put it here in case it is useful:

InstallArchives() failed: (Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 258222 files and directories currently installed.)
Removing jdownloader ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for desktop-file-utils ...
Processing triggers for python-gmenu ...
Rebuilding /usr/share/applications/desktop.en_US.UTF8.cache...
Processing triggers for hicolor-icon-theme ...
Processing triggers for python-support ...
Setting up linux-image-2.6.38-8-generic (2.6.38-8.42) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.38-8-generic
Running postinst hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 1: /etc/default/grub: Permission denied
User postinst hook script [/sbin/update-grub] exited with value 1
dpkg: error processing linux-image-2.6.38-8-generic (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-2.6.38-8-generic; however:
  Package linux-image-2.6.38-8-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 2.6.38.8.22); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
No apport report written because MaxReports is reached already
Errors were encountered while processing:
 linux-image-2.6.38-8-generic
 linux-image-generic
 linux-generic
Setting up linux-image-2.6.38-8-generic (2.6.38-8.42) ...
Running depmod.
update-initramfs: Generating /boot/initrd.img-2.6.38-8-generic
Running postinst hook script /sbin/update-grub.
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 1: /etc/default/grub: Permission denied
User postinst hook script [/sbin/update-grub] exited with value 1
dpkg: error processing linux-image-2.6.38-8-generic (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-2.6.38-8-generic; however:
  Package linux-image-2.6.38-8-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 2.6.38.8.22); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured

What I have to do? Is there any way to put the files that I deleted back?

Best Answer

There's a permission error when accessing /etc/default/grub which let's the update process fail.

As your current system seems to be broken, use a live CD to access it via the chroot method.

  1. See points 1 - 5 in this answer on how to chroot into your system.

  2. Check with ls -al /etc/default/grub that the file has following permissions:

    -rw-r--r-- 1 root root 1310 2011-03-31 22:21 /etc/default/grub
    
  3. If it hasn't, run

    chmod 644 /etc/default/grub
    
  4. Now let the system continue the upgrade:

    dpkg --configure -a
    

    If you get warnings that tell you to run apt-get install -f just do so.

  5. Just to make sure:

    update-initramfs -c -k all
    

    If that creates something, then at least you got a kernel to boot. Make sure it's in your kernel list at boot:

    update-grub
    
  6. Follow the steps 7. and 8. in the above linked answer.

Related Question