I use debian 9. For some reason the partition where my /boot lies is broken, e2fsck reported many errors. Somehow I am still able to boot into emergency mode. I can format that partition. How do I write everything needed (grub, kernel, etc.) there again?

  • 1
    Use debian installation media to boot into recovery mode, then chroot to your installed system. You can then reformat&reinstall (kernel and grub) to your boot partition. – sebasth Sep 3 '17 at 13:06

You have luck, everything in /boot can be easily reproduced automatically.

  1. Boot into rescue mode.
  2. Unmount /boot (if it is mounted - it is possible, that it can't be mounted. The command is: umount /boot)
  3. Fix your /boot filesystem. If it is ext2-3-4, then the command: e2fsck -f -y -C0 /dev/your-boot-partition. These are very agressive, enforcing-destructive flags, but you don't have to be very careful with the data on it - all of it is reporducible automatically. And, if it runs without a problem, you can be sure, that finally your /boot filesystem will be okay.
  4. If the e2fsck output didn't say any terrible (P > 90%), then your /boot is probably already fixed, and you can reboot. But if not, then you can have an unbootable system.
  5. Mount the partition again (mount /boot)
  6. Check, which packages installed anything into /boot. This can be done by the command dpkg -S /boot. In my case, the result is this:

# dpkg -S /boot
linux-image-4.4.0-38-lowlatency, memtest86+, grub2-theme-mint, memtest86, linux-image-4.4.0-38-generic, base-files: /boot

Then, you can simply reinstall these packages by the command

apt-get --reinstall install linux-image-4.4.0-38-lowlatency memtest86+ grub2-theme-mint memtest86 linux-image-4.4.0-38-generic base-files

There are also various boot and config files there, but the (re)install script of these packages will automatically re-construct them all.

It should be enough, but if you want to be very, very sure, you can also regenerate the boot files again, by hand, with the commands


...and reinstall grub to the MBR by

grub-install /dev/your-boot-disk (most probably /dev/sda)

In the - improbable - case that something would go wrong and your system becomes unbootable, you can do nearly the same steps from a rescue CD/pendrive. The details are in this answer.

Extension: after all, you may check the files restored by the e2fsck in /boot/lost+found. You don't need them, because all the data in them are already reproduced. To save place on the (typically, small) boot partition, you may delete them.

  • I did this with chroot from a liveusb, because otherwise my internet connection woudln't work because of missing firmware. It worked thanks. – CrabMan Sep 3 '17 at 14:02

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.