Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I deleted some essential kernels parts to enlarge the free space on my boot partition. First I proceed as in this link. However the problem is not exactly the same as in the link (see answer from Eliah below). What I tried first was the following, first output of my partition scheme:

ubuntu@ubuntu:~$  sudo parted -l
Model: ATA ST3500418AS (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      32.3kB  535MB   535MB   primary  ext4            boot
 2      535MB   5914MB  5379MB  primary  linux-swap(v1)
 3      5914MB  106GB   100GB   primary  ext4
 4      106GB   500GB   394GB   primary  ext4


Model: WD 5000AAC External (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End    Size   Type     File system  Flags
 1      32.3kB  500GB  500GB  primary  ext4


Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0
has been opened read-only.
Error: Can't have a partition outside the disk!                           

ubuntu@ubuntu:~$ 

I have the boot partition on sda1 , sda2 is my swap partition, sda3 is my root directory and sda4 is my home partition. I followed the instruction on the second answer (by Eliah). This means:

1.

     ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt 
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev 
ubuntu@ubuntu:~$ sudo mount /dev/sda1 /mnt/boot
  1. Then I chrooted:

        ubuntu@ubuntu:~$ sudo chroot /mnt
        root@ubuntu:/# mount -t proc none /proc
        root@ubuntu:/# mount -t sysfs none /sys
        root@ubuntu:/# mount -t devpts none /dev/pts
        root@ubuntu:/# export HOME=/root
        root@ubuntu:/# export LC_ALL=C
    
  2. I tried to install new kernel:

     apt-get update
     apt-get -y install linux-image-generic
    

Here I get the following error:

root@ubuntu:/# apt-get -y install linux-image-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-image-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-3.8.0-29-generic (3.8.0-29.42) ...
Internal Error: Could not find image (/boot/vmlinuz-3.8.0-29-generic)
dpkg: error processing linux-image-3.8.0-29-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-extra-3.8.0-29-generic:
 linux-image-extra-3.8.0-29-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-extra-3.8.0-29-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-3.8.0-29-generic; however:
  Package linux-image-extra-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-imNo apport report written because the error message indicates its a followup error from a previous failure.
     No apport report written because the error message indicates its a followup error from a previous failure.
                               No apport report written because MaxReports is reached already
             age:
 linux-image depends on linux-image-generic; however:
  Package linux-image-generic is not configured yet.

dpkg: error processing linux-image (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-3.8.0-29-generic
 linux-image-extra-3.8.0-29-generic
 linux-image-generic
 linux-image
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ubuntu:/# 


umount /proc || umount -lf /proc
umount /sys /dev/pts
exit
sudo umount /mnt/dev /mnt

I also tried to uninstall everything and run

apt-get install linux-generic linux-image-generic linux-headers-generic

and of course

update-grub

I'm still getting the memtest while booting. As Eliah pointed out, the above solution does not apply in my case. So I followed the instructions in his answer below. However this does not solve the problem. I got the following outputs:

   ubuntu@ubuntu:~$ sudo mount /dev/sda3 /mnt
ubuntu@ubuntu:~$ sudo mount --bind /dev /mnt/dev
ubuntu@ubuntu:~$ sudo mount /dev/sda1 /mnt/boot
ubuntu@ubuntu:~$ sudo chroot /mnt
root@ubuntu:/# mount -t proc none /proc
root@ubuntu:/# mount -t sysfs none /sys
root@ubuntu:/# mount -t devpts none /dev/pts
root@ubuntu:/# export HOME=/root
root@ubuntu:/# export LC_ALL=C

then running apt-get update followed by the suggested:

root@ubuntu:/# apt-get -y --purge --reinstall install linux-image-3.8.0-29-generic linux-image-extra-3.8.0-29-generic linux-image-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 3 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/43.3 MB of archives.
After this operation, 0 B of additional disk space will be used.
dpkg: warning: files list file for package 'linux-image-3.8.0-29-generic' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'initramfs-tools' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'linux-image-extra-3.8.0-29-generic' missing; assuming package has no files currently installed
(Reading database ... 251414 files and directories currently installed.)
Preparing to replace linux-image-3.8.0-29-generic 3.8.0-29.42 (using .../linux-image-3.8.0-29-generic_3.8.0-29.42_amd64.deb) ...
Done.
Unpacking replacement linux-image-3.8.0-29-generic ...
Preparing to replace linux-image-extra-3.8.0-29-generic 3.8.0-29.42 (using .../linux-image-extra-3.8.0-29-generic_3.8.0-29.42_amd64.deb) ...
Unpacking replacement linux-image-extra-3.8.0-29-generic ...
Preparing to replace linux-image-generic 3.8.0.29.47 (using .../linux-image-generic_3.8.0.29.47_amd64.deb) ...
Unpacking replacement linux-image-generic ...
Setting up linux-image-3.8.0-29-generic (3.8.0-29.42) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Failed to symbolic-link /boot/initrd.img-3.8.0-29-generic to initrd.img:File exists at /var/lib/dpkg/info/linux-image-3.8.0-29-generic.postinst line 614.
dpkg: error processing linux-image-3.8.0-29-generic (--configure):
 subprocess installed post-installation script returned error exit status 17
dpkg: dependency problems prevent configuration of linux-image-extra-3.8.0-29-generic:
 linux-image-extra-3.8.0-29-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-extra-3.8.0-29-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.8.0-29-generic; however:
  Package linux-image-3.8.0-29-generic is not configured yet.
 linux-image-generic depends on linux-image-extra-3.8.0-29-generic; however:
  Package linux-image-extra-3.8.0-29-generic is not configured yet.

dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                          No apport report written because the error message indicates its a followup error from a previous failure.
                                                    Errors were encountered while processing:
 linux-image-3.8.0-29-generic
 linux-image-extra-3.8.0-29-generic
 linux-image-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@ubuntu:/# 
share|improve this question
    
@EliahKagan If I follow the instructions I get the following issue, see my edited question –  math Aug 26 '13 at 10:26
    
Can you edit your question to include all the details of what happened? The forum topic you linked to contains a variety of information and it's not clear which specific challenge you've come up against. –  Eliah Kagan Aug 26 '13 at 10:28
    
Does apt-get work? –  Dillmo Aug 26 '13 at 11:05
    
@EliahKagan I edited my question as you said. I hope everything is clear now. I followed exactly your answer, however there was a problem using apt-get -y linux-image-generic. –  math Aug 26 '13 at 12:32
    
@Dillmo Yes, I can run for example apt-get update etc, but there is the error message (see my edited question) if I want to install new linux-image. –  math Aug 26 '13 at 12:33
show 2 more comments

3 Answers

The answers there are written for situations where there are no kernels because the packages that provide them have been removed.

Your situation is similar but a little different. It seems like what has happened on your system is that there are no kernels because their files have been manually deleted (or deleted by some automated process other than package deinstallation). It seems that, as far as the package manager is concerned, you still have kernels installed.

To solve this, it might be sufficient simply to tell the package manager to reinstall the kernel package.

You ran this command:

apt-get -y install linux-image-generic

Using the same procedure (including the apt-get update command before it), try replacing that apt-get -y install command with this one:

apt-get -y --purge --reinstall install linux-image-3.8.0-29-generic linux-image-extra-3.8.0-29-generic linux-image-generic

(The --purge flag is optional, as this problem is not related to systemwide configuration files. But it shouldn't hurt.)

That will uninstall the packages that are not working (due to deleted files), then reinstall them, ensuring that all their files are copied from the package archives. It shouldn't depend on any package files being present, so it should work even though some package files appear to have been manually deleted.

linux-image-generic is a metapackage; installing it causes the latest stable kernel for your system to be installed, because linux-image-generic declares the packages providing that kernel as dependencies. Stipuating that linux-image-generic is to be reinstalled "from scratch" does not necessarily cause all of its dependencies to be reinstalled, which is why I've listed its relevant dependencies explicitly in the command above.

I got their names (linux-image-extra-3.8.0-29-generic and linux-image-extra-3.8.0-29-generic) from the output you included in your question. Someone else experiencing this problem will not necessarily want to stipulate exactly those packages for installation, but should instead see what packages linux-image-generic depends on, and explicitly reinstall at least the package that is missing files.

Thus, the key part of the output that led me to suggest this solution was:

Setting up linux-image-3.8.0-29-generic (3.8.0-29.42) ...
Internal Error: Could not find image (/boot/vmlinuz-3.8.0-29-generic)
dpkg: error processing linux-image-3.8.0-29-generic (--configure):

It's possible this won't work. That could happen if the packages are broken in a way that prevents the package manager from uninstalling them. If that or any other problems occur, then please update your question with details.

(For people besides the author of this question--if that happens and the information here doesn't enable you to solve it, post a new question with as many details as possible, or add details to your question if you've already posted one about the problem.)

share|improve this answer
    
Thanks for your answer, see my edit (edit 2 for eliah). Similar issue –  math Aug 26 '13 at 19:24
    
I also edited my question to clarify what the actual problem is. Again, thanks for your patience. Maybe the "This question may already have an answer here" should be removed, since my problem is different. –  math Aug 26 '13 at 19:35
    
Have you seen my updated question? Should I provide more details? If so let me know. Thanks for your help –  math Aug 27 '13 at 14:32
    
strange thing is, that now it uses the following kernel: root@ubuntu:/# uname -r 3.5.0-17-generic. So the ouput of uname -r is the 3.5.0-17. –  math Aug 27 '13 at 16:23
    
@math It uses that kernel since you applied that solution? If so, I'd guess that you can upgrade the kernel just by running sudo apt-get update followed by sudo apt-get upgrade (both after booting into the system normally, as whatever kernel was successfully installed should allow). –  Eliah Kagan Aug 27 '13 at 19:04
add comment

Your problem is: E: Sub-process /usr/bin/dpkg returned an error code (1)

Here is how to fix dpkg error (1):

Open terminal and check your current kernel:

uname -r
DO NOT REMOVE THIS KERNEL!

Next, type the command below to view / list all installed kernels on your system:

dpkg --list | grep linux-image

To remove all unused kernels, run now this command:

sudo (aptitude or apt-get) purge ~ilinux-image-\[0-9\]\(\!uname -r\)

Finally, run the command below to update grub:

sudo update-grub and sudo update-grub2

And reboot your system.

Then run:

sudo apt-get update
sudo apt-get install linux-image-uname -r
sudo apt-get install linux-headers-uname -r

And then finaly run:

sudo update-grub and sudo update-grub2

And reboot again.

Regards, Andrie

share|improve this answer
1  
What exactlt do you mean? The link is about deleting old kernels, I do not see how this is related to the Sub-process issues. Sorry nescience –  math Aug 26 '13 at 19:45
    
I should also add, that I can't install synaptic, getting the same dpkg error –  math Aug 26 '13 at 19:56
    
Thanks for the edit, however the following command does not work:apt-get purge ~ilinux-image-\[0-9\]\(\!uname -r\). I get the error message: E: Command line option 'r' [from -r)] is not known. Thanks for your help. –  math Aug 27 '13 at 9:11
    
Sorry uname -r must be in ` this `- Regards –  Andrie Vorster Aug 27 '13 at 12:03
    
Still getting a error message: root@ubuntu:/# apt-get purge ~ilinux-image-\[0-9\]\(\!uname -r`) Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package ~ilinux-image-[0-9](!3.5.0-17-generic) E: Couldn't find any package by regex '~ilinux-image-[0-9](!3.5.0-17-generic) . Thanks for your patience –  math Aug 27 '13 at 14:26
show 3 more comments

A friend solved the problem. He suggested the following, which worked for me:

apt-get purge grub grub-pc grub-common 
apt-get install grub-common grub-pc 
update-grub
share|improve this answer
    
Good idea! I had not thought of reinstalling the GRUB package (which is what was done here, and is not the same as the more common operation of reinstalling GRUB to the MBR). A number of problems installing and uninstalling kernels relate to scripts that modify GRUB, so it makes sense that this solution would work. I'm glad this worked. By the way, the first two commands could probably be done with one: apt-get --purge --reinstall grub-common grub-pc –  Eliah Kagan Aug 27 '13 at 19:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.