A
A
Alexey Sundukov2013-12-25 10:30:05
ubuntu
Alexey Sundukov, 2013-12-25 10:30:05

How to upgrade Ubuntu 12.04 kernel?

There was a problem with the fact that apt-get stopped working (I don’t risk using -f yet). The reason is that my kernel is linux-image-3.2.0-29-generic, and the latest one is linux-image-3.2.0-57-generic, but apt couldn't update it, so I decided to update from the deb package:

# dpkg -i linux-image-3.2.0-57-generic_3.2.0-57.87_amd64.deb 
(Reading database ... 94087 files and directories currently installed.)
Preparing to replace linux-image-3.2.0-57-generic 3.2.0-57.87 (using linux-image-3.2.0-57-generic_3.2.0-57.87_amd64.deb) ...
Done.
Unpacking replacement linux-image-3.2.0-57-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 3.2.0-57-generic /boot/vmlinuz-3.2.0-57-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 3.2.0-57-generic /boot/vmlinuz-3.2.0-57-generic
Setting up linux-image-3.2.0-57-generic (3.2.0-57.87) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
failed to move /initrd.img:Invalid cross-device link at /var/lib/dpkg/info/linux-image-3.2.0-57-generic.postinst line 495.
dpkg: error processing linux-image-3.2.0-57-generic (--install):
 subprocess installed post-installation script returned error exit status 18
Errors were encountered while processing:
 linux-image-3.2.0-57-generic

I'm looking at this script:
# sed -n 495,500p /var/lib/dpkg/info/linux-image-3.2.0-57-generic.postinst
  rename("$kimage", "$kimage.$$") ||
    die "failed to move " . $image_dest . "$kimage:$!";
  warn "mv $kimage $kimage.$$" if $DEBUG;
  my $Old = $src_dir;
  my $cwd;

And I understand that he is trying to rename the old image, but he can’t do it (through hardlink? I’m just not familiar with the pearl). The reason is clear:
# ls -l /initrd.img 
lrwxrwxrwx 1 root root 33 Sep 12  2012 /initrd.img -> /boot/initrd.img-3.2.0-29-generic

In this case, the root fs:
# mount -l -t xfs
/dev/md2 on / type xfs (rw,usrquota,prjquota)

, and boot:
# mount -l -t ext3
/dev/md1 on /boot type ext3 (rw)

Right now I'm sitting and trying to figure out how to upgrade with a minimum of effort, but not to drop the system.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Ilya Evseev, 2013-12-29
@alekciy

A very difficult case:

mkdir /boot2
tar cf - -C /boot . | tar xf - -C /boot2
umount /boot
rm /boot
mv /boot2 /boot

After that apt-get remove etc.
When all is well, mount /boot again

I
Ilya Evseev, 2013-12-26
@IlyaEvseev

what do "apt-get check" and "apt-get install -f" say?
if apt is broken, then it is better to fix it, and not to invent workaround crutches.

A
Alexey Sundukov, 2013-12-26
@alekciy

#apt-get check
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 linux-generic : Depends: linux-image-generic (= 3.2.0.54.64) but 3.2.0.57.68 is installed
 linux-image : Depends: linux-image-generic (= 3.2.0.54.64) but 3.2.0.57.68 is installed
 linux-server : Depends: linux-image-server (= 3.2.0.57.68) but it is not installed
                Depends: linux-headers-server (= 3.2.0.57.68) but it is not installed
E: Unmet dependencies. Try using -f.

Unmet is because of linux-server which I tried to download from deb file. -f is of course a little scary to run, but did not help in the end:
# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux linux-generic linux-image
The following packages will be upgraded:
  linux linux-generic linux-image
3 upgraded, 0 newly installed, 0 to remove and 177 not upgraded.
8 not fully installed or removed.
Need to get 0 B/5,118 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]?
Setting up linux-image-3.2.0-57-generic (3.2.0-57.87) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
failed to move /initrd.img:Invalid cross-device link at /var/lib/dpkg/info/linux-image-3.2.0-57-generic.postinst line 495.
dpkg: error processing linux-image-3.2.0-57-generic (--configure):
 subprocess installed post-installation script returned error exit status 18
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-57-generic; however:
  Package linux-image-3.2.0-57-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.
                                                                                                          dpkg: dependency problems prevent configuration of linux-generic:
 linux-generic depends on linux-image-generic (= 3.2.0.54.64); however:
  Version of linux-image-generic on system is 3.2.0.57.68.
 linux-generic depends on linux-headers-generic (= 3.2.0.54.64); however:
  Version of linux-headers-generic on system is 3.2.0.57.68.
dpkg: error processing linux-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image:
 linux-image depends on linux-image-generic (= 3.2.0.54.64); however:
  Version of linux-image-generic on system is 3.2.0.57.68.
dpkg: error processing linux-image (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux:
 linux depends on linux-image (= 3.2.0.54.64); however:
  Package linux-image is not configured yet.
dpkg: error processing linux (--configure):
 dependency problems - leaving unconfigured
Setting up linux-image-3.2.0-54-generic (3.2.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
      No apport report written because MaxReports is reached already
                                                                    0-54.82) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
failed to move /initrd.img:Invalid cross-device link at /var/lib/dpkg/info/linux-image-3.2.0-54-generic.postinst line 495.
dpkg: error processing linux-image-3.2.0-54-generic (--configure):
 subprocess installed post-installation script returned error exit status 18
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of linux-image-server:
 linux-image-server depends on linux-image-3.2.0-57-generic; however:
  Package linux-image-3.2.0-57-generic is not configured yet.
dpkg: error processing linux-image-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              dpkg: dependency problems prevent configuration of linux-server:
 linux-server depends on linux-image-server (= 3.2.0.57.68); however:
  Package linux-image-server is not configured yet.
dpkg: error processing linux-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-image-3.2.0-57-generic
 linux-image-generic
 linux-generic
 linux-image
 linux
 linux-image-3.2.0-54-generic
 linux-image-server
 linux-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

Of course, I will drink linux-server, but I suspect that in the end it still won’t let me upgrade. The authors of the package clearly did not expect that the symlink would end up on another fs.

A
Alexey Sundukov, 2013-12-28
@alekciy

@IlyaEvseev I tried that, even more, I did purge. But everything is clear:

]$ sudo apt-get remove linux-server linux-image-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package linux-image-server is not installed, so not removed
Package linux-server is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 177 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-3.2.0-57-generic (3.2.0-57.87) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
failed to move /initrd.img:Invalid cross-device link at /var/lib/dpkg/info/linux-image-3.2.0-57-generic.postinst line 495.
dpkg: error processing linux-image-3.2.0-57-generic (--configure):
 subprocess installed post-installation script returned error exit status 18
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-57-generic; however:
  Package linux-image-3.2.0-57-generic is not configured yet.
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image:
 linux-image depends on linux-image-generic (= 3.2.0.57.68); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-image (--configure):
 dependency problems - leaving unconfigured
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.2.0-57-generic
 linux-image-generic
 linux-image
E: Sub-process /usr/bin/dpkg returned an error code (1)
]$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 177 not upgraded.
3 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up linux-image-3.2.0-57-generic (3.2.0-57.87) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
failed to move /initrd.img:Invalid cross-device link at /var/lib/dpkg/info/linux-image-3.2.0-57-generic.postinst line 495.
dpkg: error processing linux-image-3.2.0-57-generic (--configure):
 subprocess installed post-installation script returned error exit status 18
dpkg: dependency problems prevent configuration of linux-image-generic:
 linux-image-generic depends on linux-image-3.2.0-57-generic; however:
  Package linux-image-3.2.0-57-generic is not configured yet.
dpkg: error processing linux-image-generic (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-image:
 linux-image depends on linux-image-generic (= 3.2.0.57.68); however:
  Package linux-image-generic is not configured yet.
dpkg: error processing linux-image (--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.2.0-57-generic
 linux-image-generic
 linux-image
E: Sub-process /usr/bin/dpkg returned an error code (1)

As I understand it, the package maker could not even imagine such a breakdown of disks, so it seems that it will no longer be possible to update the kernel from standard packages. And I don’t want to freeze the current version of the kernel in apt, because it is full of holes and a local user can elevate privileges to root.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question