Skip to content

Instantly share code, notes, and snippets.

@jayluxferro
Last active September 26, 2017 07:09
Show Gist options
  • Save jayluxferro/57260a594404678b304616f51f258b7d to your computer and use it in GitHub Desktop.
Save jayluxferro/57260a594404678b304616f51f258b7d to your computer and use it in GitHub Desktop.
Fix linux grub bootloader

Fixing Grub Bootloader

  1. Make a bootable device of the distribution you are using(debian,kali,ubuntu)
  2. Open the terminal
  3. Type lsblk to list the various blocks of the hard disk
root@sperixlabs: ~# lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0 526.5G  0 part /
├─sda2   8:2    0   500M  0 part 
├─sda3   8:3    0 396.7G  0 part 
└─sda4   8:4    0   7.9G  0 part [SWAP]

  1. Note the name of the root partition on which your linux is installed. In this case it is sda1 and the main block is sda.
  2. Mount the root partition to the /mnt directory
root@sperixlabs: ~# mount /dev/sda1 /mnt
  1. If /mnt does not exist create it using the command
root@sperixlabs: ~# mkdir /mnt
  1. After mounting the root partition in the /mnt directory run the following commands
root@sperixlabs: ~# mount --bind /dev/ /mnt/dev/
root@sperixlabs: ~# mount --bind /dev/pts /mnt/dev/pts
root@sperixlabs: ~# mount --bind /proc/ /mnt/proc
root@sperixlabs: ~# mount --bind /sys/ /mnt/sys
  1. chroot into the /mnt directory using the command
root@sperixlabs: ~# chroot /mnt
  1. Afterwards, install the grub to your main block and update the bootloader. In this case the main block is sda
root@sperixlabs: ~# grub-install /dev/sda
root@sperixlabs: ~# update-grub
  1. Exit from the terminal and reboot your machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment