I mistakenly deleted the /boot folder from my filesystem, rebooted, and all I get now is this:
error: file '/boot/grub/i368-pc/linux.mod' not found. grub rescue>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Oops!
Here’s what to do:
- Boot a live distro. This can be your Ubuntu installation disc or another one such as Knoppix.
-
Find the drive/partition where you have installed your root filesystem. To do this you can open a terminal and run either
sudo parted -lorsudo fdisk -l. If you can’t tell, then edit your question and add the output. -
Assuming that your root partition that you found from the last step is
/dev/sdxy(xshould be another letter andyshould be a number), then run the following commands in a terminal:mkdir mnt sudo mount /dev/sdxy mnt sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sys sudo chroot mnt
-
You will now be inside a
chrootenvironment meaning that running commands here is equivalent to running them on your installed system. The first thing you want to do is reinstall GRUB2 to the device so that it copies the correct files into the/bootfolder. To do this run the following with the drive that your root partition is on (ie/dev/sdxywith the number (y) removed):grub-install /dev/sdx
-
You now want to find out which packages you have installed that have files in the boot directory and reinstall them. This will replace the kernel images that have been deleted among other things. The command to find the packages is:
dpkg -S /boot
And to reinstall them:
apt-get --reinstall install ...
Where
...is replaced with the names of packages from the first command. Do not include the commas, just have the package names with spaces to separate.This step will probably require internet access (unless the packages are already in the cache), so make sure you are connected if there is an problem.
-
Since you will have deleted your kernels and reinstalled them, this should have triggered a GRUB2 update automatically. But just in case they haven’t, you can run:
update-grub
-
Reboot and things should now be fixed. One issue that I had the last time I did something similar was that Windows installs where not found by
update-grubwhen run in thechrootdue to a bug inos-prober. If this is an issue, just runsudo update-grubagain in the repaired system.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0