I happen to have deleted the /boot directory on my system instead of on the one I was supposed to.. I found this in order to restore it, however I had problems with apt --reinstall so I decided to remove and install the packages manually. Probably not the brightest idea, now have 2 broken images that I do not know how to fix.

Running dpkg --audit tells me

The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 linux-image-4.15.0-42-generic Signed kernel image generic
 linux-image-4.15.0-43-generic Signed kernel image generic

Running dpkg --configure linux-image-4.15.0-42-generic

Setting up linux-image-4.15.0-42-generic (4.15.0-42.45) ...
Processing triggers for linux-image-4.15.0-42-generic (4.15.0-42.45) ...
run-parts: failed to exec /etc/kernel/postinst.d/dkms: No such file or directory
run-parts: /etc/kernel/postinst.d/dkms exited with return code 1
dpkg: error processing package linux-image-4.15.0-42-generic (--configure):
 installed linux-image-4.15.0-42-generic package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:

However /etc/kernel/postinst.d/dkms exists

~$ ls -l /etc/kernel/postinst.d/dkms
-rwxr-xr-x 1 root root 1120 авг 31  2016 /etc/kernel/postinst.d/dkms

My machine is still running though, is it possible to save it?


Just tried to run dkms manually and found out /bin/bash was missing. Installed it with apt install bash and then issued the commands

dpkg --audit
apt install -f

Everything looks normal now, however after reboot there is no ubuntu boot option in grub..

  • Boot with a Live Ubuntu Disc
  • Mount the partition/s with Ubuntu file system, on /mnt

  • Example

    sudo mount /dev/sdxx /mnt
    sudo mount /dev/sdxy /mnt/boot
    sudo mount /dev/sdxz /mnt/boot/efi

    Where sdx=disk, sdxx="/" partition, sdxy="boot" partition,sdxz="efi" partition

    then run

    for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
    sudo chroot mnt
  • Most importantly, since you have lost your /boot/grub/efi and may be /boot/grub/efi also.

    • Find your boot type

      [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD" 
    • If internet problem.

      echo "nameserver" >/etc/resolv.conf


      cp /mnt/etc/resolv.conf /etc/resolv.conf
    • For legacy/bios boot

      apt install --reinstall grub-pc grub-common
    • For UEFI(efi) boot

      apt install --reinstall grub-common grub-efi grub-efi-amd64 grub-efi-amd64-bin
    • And

      grub-install /sdx # no apt infront
    • Now run

      dpkg -S /boot
      sudo dpkg --audit

to find the packages needed. Install the packages.

  • Then

    apt --fix-missing install
    update-initramfs -u 


    for i in /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done

    Unmount mounted partitions.


    sudo umount /mnt/boot/efi
    sudo umount /mnt/boot
    sudo umount /mnt
    sudo reboot
  • For errors after rebooting.

    sudo dpkg --configure -a
| improve this answer | |
  • I just did all that, all commands run fine, apt doesn't report any errors, says images are installed - everything looks good, except when I reboot there is only windows and system setup (bios) in grub.. – php_nub_qq Jan 12 '19 at 13:43
  • also when reinstalling the images I see it says it's adding boot menu entry for windows boot manager and efi firmware configuration, not sure if there should be such message for grub which is missing? grub-probe: error: cannot find a GRUB drive for /dev/sdc1. Check your device.map. Found Windows Boot Manager on /dev/sdb1@/EFI/Microsoft/Boot/bootmgfw.efi Adding boot menu entry for EFI firmware configuration where /dev/sdc1 is my ubutnu live flash drive – php_nub_qq Jan 12 '19 at 14:01
  • 1
    @php_nub_qq seethe edited answer. I see that you have efi boot. – Vijay Jan 12 '19 at 18:42
  • Ok we're certainly going somewhere. I am now seeing ubuntu and advanced options for ubuntu in grub, however when I chose to boot in ubuntu it takes unusually long and then flashes a console screen with a message of some files being checked or something and then a bunch of lines saying something about a key that is not trusted, I can only provide so much information because the screen flashes for probably less than a second. After this a terminal appears as if I'm running a server version of ubuntu which I'm not, and I can't login because any input from the keyboard appears to be ignored --> – php_nub_qq Jan 12 '19 at 20:20
  • Which is also the case when going in recovery mode, keyboard is not working but it works in grub menu. – php_nub_qq Jan 12 '19 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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