Restore grub
My server was installed a long time ago and it seems that the partitions were created in a way that grub does not like. And when grub does not like something you have good chances of having a computer not booting.
Since I have the problem from time to time, let's write a reminder on how to fix this.
Sometime there are grub updates, and on the next reboot, well, nothing happens. Hopefully, my hosting provider provides an option to boot my server on a Ubuntu live CD (my server is running Debian but that's fine).
When Ubuntu has finished booting, I can ssh
on it and list my hard drive partitions:
# fdisk -l /dev/sda
(…)
Device Boot Start End Blocks Id System
/dev/sda1 1 12 96389+ 83 Linux
/dev/sda2 13 19324 155123640 83 Linux
/dev/sda3 19325 19454 1044225 83 Linux
Here sda1
is my boot partition, sda2
is my root partition and sda3
is swap. Let's mount that:
# mount /dev/sda2 /mnt
# mount /dev/sda1 /mnt/boot
Now we have to change the root
directory from the live CD to my server's disk so we can simulate being running on my server's disk:
# chroot /mnt
And now we can reinstall grub:
# grub-install /dev/sda
In my case I have to give the --force
option to install grub. That's all, I can now restart my Debian server.
Comments Add one by sending me an email.