无法删除或安装内核

无法删除或安装内核

我意外删除了我的/boot分区,但我能够用它恢复它grub-install

我正在尝试通过本指南再次 chroot 并安装内核:意外删除所有内核后如何恢复系统?

但是,当我尝试删除或安装该包时出现以下错误:

root@ubuntu:/# apt-get install -f

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  thermald
Use 'apt-get autoremove' to remove it.
The following packages will be REMOVED:
  linux-image-extra-4.2.0-25-generic
0 upgraded, 0 newly installed, 1 to remove and 33 not upgraded.
2 not fully installed or removed.
After this operation, 162 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 411666 files and directories currently installed.)
Removing linux-image-extra-4.2.0-25-generic (4.2.0-25.30) ...
depmod: FATAL: could not load /boot/System.map-4.2.0-25-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
Running in chroot, ignoring request.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
mv: ‘/boot/initrd.img-4.2.0-25-generic.new’ and ‘/boot/initrd.img-4.2.0-25-generic’ are the same file
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
dpkg: error processing package linux-image-extra-4.2.0-25-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-4.2.0-25-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)

更新:它似乎卡在了以下命令上

root@ubuntu:/# update-initramfs -c -t -k 4.2.0-25-generic -b /boot
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
mv: ‘/boot/initrd.img-4.2.0-25-generic.new’ and ‘/boot/initrd.img-4.2.0-25-generic’ are the same file

root@ubuntu:/# ls -l /boot

ubuntu@ubuntu:~$ ls -l /boot

total 5430
-rw-r--r-- 1 root root 1268815 Apr 17  2015 abi-3.19.0-15-generic
-rw-r--r-- 1 root root  177656 Apr 17  2015 config-3.19.0-15-generic
drwxr-xr-x 1 root root      60 Jan 20 21:39 grub
-rw-r--r-- 1 root root  164216 Mar  6  2015 memtest86+.bin
-rw-r--r-- 1 root root  165892 Mar  6  2015 memtest86+.elf
-rw-r--r-- 1 root root  166396 Mar  6  2015 memtest86+_multiboot.bin
-rw------- 1 root root 3615358 Apr 17  2015 System.map-3.19.0-15-generic

root@ubuntu:/# apt-get install --reinstall linux-image-4.2.0-25-generic

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 33 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for linux-image-4.2.0-25-generic:amd64

root@ubuntu:/# dpkg --configure linux-image-4.2.0-25-generic

Setting up linux-image-4.2.0-25-generic (4.2.0-25.30) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
initrd.img(/boot/initrd.img-4.2.0-25-generic
) points to /boot/initrd.img-4.2.0-25-generic
 (/boot/initrd.img-4.2.0-25-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-4.2.0-25-generic.postinst line 491.
vmlinuz(/boot/vmlinuz-4.2.0-25-generic
) points to /boot/vmlinuz-4.2.0-25-generic
 (/boot/vmlinuz-4.2.0-25-generic) -- doing nothing at /var/lib/dpkg/info/linux-image-4.2.0-25-generic.postinst line 491.
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
run-parts: executing /etc/kernel/postinst.d/dkms 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
Running in chroot, ignoring request.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.2.0-25-generic /boot/vmlinuz-4.2.0-25-generic
update-initramfs: Generating /boot/initrd.img-4.2.0-25-generic
mv: ‘/boot/initrd.img-4.2.0-25-generic.new’ and ‘/boot/initrd.img-4.2.0-25-generic’ are the same file
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.2.0-25-generic.postinst line 1025.
dpkg: error processing package linux-image-4.2.0-25-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 linux-image-4.2.0-25-generic

我怎样才能解决这个问题?

答案1

上面有无法处理某些内容的提示,postinst.d所以我查看了它正在运行的脚本并找到了它们。

我做了一个rm -rf /var/lib/dpkg/info/linux-image-4.2.0-25-generic.*,其中有一些正在使用的文件,但不知何故它们有问题。我删除了它们,运行.postrm后就再也没有重新安装错误了!耶。感谢大家为我指明了正确的方向。还有另一个关于重新安装 grub 的提示,我用 Boot Repair 做了这个,之后我能够更好地找出问题所在。.listdpkg --configure -a

相关内容