apt 更新修复

时间:2021-11-20 19:45:48

想要更新docker版本不想内核上次卸载报错了,部分软件始终无法删除

**apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
7 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up grub-pc (2.02~beta2-36ubuntu3.23) ...
/var/lib/dpkg/info/grub-pc.config: 12: /etc/default/grub: net.ifnames=0: not found
dpkg: error processing package grub-pc (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up friendly-recovery (0.2.31ubuntu2.1) ...
/usr/sbin/grub-mkconfig: 12: /etc/default/grub: net.ifnames=0: not found
dpkg: error processing package friendly-recovery (--configure):
subprocess installed post-installation script returned error exit status 127
Setting up linux-image-4.4.0-116-generic (4.4.0-116.140) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Not updating initrd symbolic links since we are being updated/reinstalled
(4.4.0-116.140 was configured last, according to dpkg)
Not updating image symbolic links since we are being updated/reinstalled
(4.4.0-116.140 was configured last, according to dpkg)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-116-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 127
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.4.0-116-generic.postinst line 1052.
dpkg: error processing package linux-image-4.4.0-116-generic (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up linux-image-4.4.0-174-generic (4.4.0-174.204) ...
dpkg: dependency problems prevent configuration of linux-image-extra-4.4.0-116-generic:
linux-image-extra-4.4.0-116-generic depends on linux-image-4.4.0-116-generic; however:
Package linux-image-4.4.0-116-generic is not configured yet.

dpkg: error processing package linux-image-extra-4.4.0-116-generic (--configure):
dependency problems - leaving unconfigured
Setting up grub-legacy-ec2 (19.4-33-gbb4131a2-0ubuntu1~16.04.1) ...
No apport report written because MaxReports is reached already
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
dpkg: error processing package grub-legacy-ec2 (--configure):
subprocess installed post-installation script returned error exit status 127
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of ubuntu-server:
ubuntu-server depends on grub-legacy-ec2; however:
Package grub-legacy-ec2 is not configured yet.

dpkg: error processing package ubuntu-server (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Processing triggers for linux-image-4.4.0-174-generic (4.4.0-174.204) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.4.0-174-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
/etc/kernel/postinst.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub

If you change this file, run ‘update-grub‘ afterwards to update

/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 127
dpkg: error processing package linux-image-4.4.0-174-generic (--configure):
subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
Errors were encountered while processing:
grub-pc
friendly-recovery
linux-image-4.4.0-116-generic
linux-image-extra-4.4.0-116-generic
grub-legacy-ec2
ubuntu-server
linux-image-4.4.0-174-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)****

apt-get autoremove linux-image-4.4.0-116-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-4.4.0-116-generic linux-image-extra-4.4.0-116-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
7 not fully installed or removed.
After this operation, 223 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 137509 files and directories currently installed.)
Removing linux-image-extra-4.4.0-116-generic (4.4.0-116.140) ...
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-116-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 127
dpkg: error processing package linux-image-extra-4.4.0-116-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Removing linux-image-4.4.0-116-generic (4.4.0-116.140) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-116-generic
run-parts: executing /etc/kernel/postrm.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postrm.d/x-grub-legacy-ec2 exited with return code 127
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-4.4.0-116-generic.postrm line 330.
dpkg: error processing package linux-image-4.4.0-116-generic (--remove):
subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
linux-image-extra-4.4.0-116-generic
linux-image-4.4.0-116-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

强制安装这个包也不行
dpkg -i --force-overwrite /var/cache/apt/archives/linux-image-4.4.0-116-generic_4.4.0-116.140_amd64.deb
(Reading database ... 137509 files and directories currently installed.)
Preparing to unpack .../linux-image-4.4.0-116-generic_4.4.0-116.140_amd64.deb ...
Examining /etc/kernel/preinst.d/
run-parts: executing /etc/kernel/preinst.d/intel-microcode 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Done.
Unpacking linux-image-4.4.0-116-generic (4.4.0-116.140) over (4.4.0-116.140) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postrm.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Setting up linux-image-4.4.0-116-generic (4.4.0-116.140) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
Not updating initrd symbolic links since we are being updated/reinstalled
(4.4.0-116.140 was configured last, according to dpkg)
Not updating image symbolic links since we are being updated/reinstalled
(4.4.0-116.140 was configured last, according to dpkg)
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-116-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Searching for GRUB installation directory ... found: /boot/grub
/etc/default/grub: line 12: net.ifnames=0: command not found
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 127
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.4.0-116-generic.postinst line 1052.
dpkg: error processing package linux-image-4.4.0-116-generic (--install):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
linux-image-4.4.0-116-generic

备份下/etc/default/grub
cp /etc/default/grub /etc/default/grub

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=2
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
net.ifnames=0
GRUB_CMDLINE_LINUX=""

删除 net.ifnames=0

更新运行

apt-get install

apt-get autoremove linux-image-4.4.0-116-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
linux-image-4.4.0-116-generic linux-image-extra-4.4.0-116-generic
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
7 not fully installed or removed.
After this operation, 223 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 131890 files and directories currently installed.)
Removing linux-image-extra-4.4.0-116-generic (4.4.0-116.140) ...
depmod: FATAL: could not load /boot/System.map-4.4.0-116-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
update-initramfs: Generating /boot/initrd.img-4.4.0-116-generic
depmod: WARNING: could not open /lib/modules/4.4.0-116-generic/modules.order: No such file or directory
depmod: WARNING: could not open /lib/modules/4.4.0-116-generic/modules.builtin: No such file or directory
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
depmod: WARNING: could not open /var/tmp/mkinitramfs_SpajqX/lib/modules/4.4.0-116-generic/modules.order: No such file or directory
depmod: WARNING: could not open /var/tmp/mkinitramfs_SpajqX/lib/modules/4.4.0-116-generic/modules.builtin: No such file or directory
run-parts: executing /etc/kernel/postinst.d/unattended-upgrades 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/update-notifier 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
run-parts: executing /etc/kernel/postinst.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Ignoring non-Xen Kernel on Xen domU host: vmlinuz-4.4.0-131-generic.efi.signed
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Replacing config file /run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done

run-parts: executing /etc/kernel/postinst.d/zz-update-grub 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-174-generic
Found initrd image: /boot/initrd.img-4.4.0-174-generic
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
done
Removing linux-image-4.4.0-116-generic (4.4.0-116.140) ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
update-initramfs: Deleting /boot/initrd.img-4.4.0-116-generic
run-parts: executing /etc/kernel/postrm.d/x-grub-legacy-ec2 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Ignoring non-Xen Kernel on Xen domU host: vmlinuz-4.4.0-131-generic.efi.signed
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Updating /boot/grub/menu.lst ... done

run-parts: executing /etc/kernel/postrm.d/zz-update-grub 4.4.0-116-generic /boot/vmlinuz-4.4.0-116-generic
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-174-generic
Found initrd image: /boot/initrd.img-4.4.0-174-generic
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
done
Setting up grub-pc (2.02~beta2-36ubuntu3.23) ...
Installing for i386-pc platform.
grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won‘t be possible.
grub-install: warning: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. However, blocklists are UNRELIABLE and their use is discouraged..
Installation finished. No error reported.
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-174-generic
Found initrd image: /boot/initrd.img-4.4.0-174-generic
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
done
Setting up friendly-recovery (0.2.31ubuntu2.1) ...
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-174-generic
Found initrd image: /boot/initrd.img-4.4.0-174-generic
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
done
Setting up linux-image-4.4.0-174-generic (4.4.0-174.204) ...
Setting up grub-legacy-ec2 (19.4-33-gbb4131a2-0ubuntu1~16.04.1) ...
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Ignoring non-Xen Kernel on Xen domU host: vmlinuz-4.4.0-131-generic.efi.signed
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Updating /boot/grub/menu.lst ... done

Setting up ubuntu-server (1.361.4) ...
Processing triggers for linux-image-4.4.0-174-generic (4.4.0-174.204) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.4.0-174-generic
W: mdadm: /etc/mdadm/mdadm.conf defines no arrays.
/etc/kernel/postinst.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Ignoring non-Xen Kernel on Xen domU host: vmlinuz-4.4.0-131-generic.efi.signed
Found kernel: /boot/vmlinuz-4.4.0-174-generic
Found kernel: /boot/vmlinuz-4.4.0-131-generic
Updating /boot/grub/menu.lst ... done

/etc/kernel/postinst.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-174-generic
Found initrd image: /boot/initrd.img-4.4.0-174-generic
Found linux image: /boot/vmlinuz-4.4.0-131-generic
Found initrd image: /boot/initrd.img-4.4.0-131-generic
done