无法删除或安装内核

我不小心删除了我的/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 

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

上面有一个提示无法处理有关postinst.d因此我查看了它运行的脚本并找到了它们。

我做了一个rm -rf /var/lib/dpkg/info/linux-image-4.2.0-25-generic.* ,其中包含一些正在使用的.postrm.list文件,这些文件因任何原因都有问题。 我删除了它们,运行dpkg --configure -a并且不再重新安装错误! 好极了。 谢谢大家指出我正确的方向。 还有一个关于重新安装grub的提示,我在Boot Repair中做了一些提示,之后我能够更好地查明事情被破坏的地方。