To restore grub bootloader you should boot the system using Live CD or Rescue mode the same operating system and architecture. For Example, Debian.
Plug-in downloaded ISO and select boot from the disk
After booting from the Debian LiveCD do all the settings on behalf of the superuser (root) or via sudo program. All the restoration procedure is carried out with superuser rights.
Enter the system and type:
sudo -s
First find out the sections of the system directories. Get the full list of the sections via fdisk
fdisk -l
Mount the section with the system directories (e.g.,/dev/sda2) to the dedicated directory (e.g., /mnt).
mount /dev/sda2 /mnt
Using ls /mnt command look through the whole list of the directories of the /dev/sda2 section to make sure you are in the right section.
ls /mnt
If you have mounted the section correctly ls command will show you these directories: /sys, /proc, /dev and others
Depending on the damage and problems we will use Debian LiveCD system files instead of those that are on the disk. We are going to create synonym files or entire directories to restore grub2. For correct work use /sys, /proc and /dev from a Debian liveCD:
mount –bind /dev /mnt/dev
mount –bind /sys /mnt/sys
mount –bind /proc /mnt/proc
mount –bind /dev /mnt/dev – indicates that /dev files are available at the synonymous address /mnt/dev
Restart the system (from the hard drive):
chroot /mnt
The system believes that /mnt is its root directory.
This method can be applicable when testing. Copy system files into a separate directory, switch back there via the chroot, test and, if everything works correctly, copy the modified files to the original, but if something goes wrong, it is possible to reset settings very quickly and not hurt the server.
If grub2 has been already installed you may upgrade it, if no, set it up in the section like in common Debian (Linux).
Grub bootloader update:
update-grub
Installation:
grub-install
Now you can start system in normal mode.