How to Repair and Install GRUB on Ubuntu

Install GRUB on Ubuntu

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

GRUB, short for Grand Unified Bootloader, is an essential Linux boot process. It manages the boot process, which enables the user to choose the operating system. Basic knowledge of how to install GRUB on Ubuntu is a fundamental and non-negotiable skill for all Linux administrators to ensure a seamless boot experience. 

In this guide, we will walk through the easy process of installing GRUB on Ubuntu, making it easy to manage your operating systems. 

Prerequisites to Install GRUB on Ubuntu

Before you start to install GRUB on Ubuntu, make sure that you complete the following checklist. 

  1. A Bootable Ubuntu Live USB/DVD 
  2. Administrative Privileges (Root or sudo access
  3. An Existing Ubuntu Installation or Target Disk – Either an installed OS or a disk where GRUB will be installed.
  4. BIOS or UEFI Mode Awareness – Know whether your system uses BIOS or UEFI, as GRUB installation differs for each.
  5. Basic Linux Command-Line Knowledge – Familiarity with commands like grub-install, update-grub, and lsblk helps in troubleshooting.
  6. Backup of Important Data 

Checking if GRUB is Installed on Ubuntu

Before you install GRUB on Ubuntu, you should check if it is already on your system. 

  1. Check GRUB Installation with the Bootloader Directory 

To check if the GRUB files already exist on your system, run the following command: 

ls /boot/grub

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

Install GRUB on Ubuntu

If the directory exists and contains files, GRUB is likely installed.

  1. Verify GRUB Installation with the grub-install Command

Execute the following command to verify GRUB installation:

grub-install –version

Install GRUB on Ubuntu 2
  1. Check Bootloader Location

To see if GRUB is installed on your disk’s Master Boot Record (MBR) or EFI partition, run:

sudo fdisk -l

Install GRUB on Ubuntu 3

For UEFI systems, check the EFI partition:

ls /boot/efi/EFI/ubuntu/

Install GRUB on Ubuntu 4

If GRUB files exist, it’s installed on your UEFI system.

  1. Verify GRUB Bootloader with efibootmgr (For UEFI Systems)

sudo efibootmgr -v

  1. Check GRUB Bootloader at System Startup

Restart your system and hold the Shift button for BIOS or Ecs/F12 for UEFI. 

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

How To Install GRUB on Ubuntu

Depending on your system, whether your system uses BIOS or UEFI, you can follow the respective steps. 

Installing GRUB on BIOS Systems

If your system is using a traditional BIOS setup, follow these steps:

  1. Identify the Target Disk

Run the following command to find your disk:

Lsblk

Install GRUB on Ubuntu 5

The main disk is usually /dev/sda or /dev/nvme0n1.

  1. Install GRUB on the MBR

Use the grub-install command:

sudo grub-install /dev/sdX

Replace /dev/sdX with your actual disk name (e.g., /dev/sda).

  1. Update the GRUB Configuration

Generate a new configuration file after installing: 

sudo update-grub

Install GRUB on Ubuntu 6
  1. Reboot the System

Reboot your system to see if the installation was successful: 

sudo reboot

Installing GRUB on UEFI Systems

Follow these steps for UEFI systems: 

  1. Mount the EFI Partition

Identify your EFI partition by running:

sudo fdisk -l | grep EFI

Install GRUB on Ubuntu 7

It is usually mounted at /boot/efi. If it’s not mounted, do so manually:

sudo mount /dev/sdXn /boot/efi

Replace /dev/sdXn with your EFI partition (e.g., /dev/sda1).

  1. Install GRUB for UEFI

Run the following command to install GRUB on the EFI system partition:

sudo grub-install –target=x86_64-efi –efi-directory=/boot/efi –bootloader-id=ubuntu

  1. Update the GRUB Configuration

Generate the GRUB configuration file by running:

sudo update-grub

  1. Reboot and Verify GRUB

Restart the system to verify installation: 

sudo reboot

You can also check GRUB entries using:

sudo efibootmgr -v

Repairing GRUB Bootloader on Ubuntu

If GRUB is missing, corrupted, or fails to boot Ubuntu, you can repair using the following methods: 

  1. Boot into a Live Ubuntu Session

Use a bootable Ubuntu USB/DVD and select try Ubuntu without installing. 

  1. Identify and Mount the Root Partition

Find your Linux partition:

lsblk

Mount it:

sudo mount /dev/sdXn /mnt

(Replace /dev/sdXn with your root partition, e.g., /dev/sda2).

  1. Mount Additional System Directories

sudo mount –bind /dev /mnt/dev

sudo mount –bind /proc /mnt/proc

sudo mount –bind /sys /mnt/sys

  1. Chroot into Your System

sudo chroot /mnt

  1. Reinstall GRUB

For BIOS Systems:

grub-install /dev/sdX

For UEFI Systems:

grub-install –target=x86_64-efi –efi-directory=/boot/efi –bootloader-id=ubuntu

  1. Update GRUB Configuration

update-grub

  1. Exit Chroot and Reboot

exit

sudo reboot

Configuring GRUB

GRUB settings can be modified in the /etc/default/grub file.

  1. Edit the GRUB Configuration File

sudo nano /etc/default/grub

  1. Common GRUB Customizations

Set Default Boot Entry by running”
GRUB_DEFAULT=0

Enable GRUB Menu at Startup
GRUB_TIMEOUT=5

Enable Recovery Mode
GRUB_DISABLE_RECOVERY=false

Change Resolution
GRUB_GFXMODE=1024×768

  1. Apply Changes

Apply the Changes by running: 

sudo update-grub

Reboot to see the updated settings.

Related Article: How to Install GCC on Ubuntu: The Only Guide You’ll Need

Troubleshooting GRUB Issues

IssueSolution
GRUB Rescue Mode (grub rescue> prompt)1. Identify partitions: ls2. Set root: set root=(hd0,1) (adjust as needed)3. Load and boot GRUB: insmod normal → normal
Missing GRUB Menu at Boot1. Edit GRUB config: sudo nano /etc/default/grub2. Set:GRUB_TIMEOUT_STYLE=menuGRUB_TIMEOUT=53. Update GRUB: sudo update-grub
Booting Directly into Windows Instead of GRUB1. Reinstall GRUB: sudo grub-install /dev/sda2. Update GRUB: sudo update-grub
GRUB Not Detecting Other OS (e.g., Dual Boot)1. Run: sudo os-prober2. Update GRUB: sudo update-grub
Broken GRUB After Kernel Update1. Boot into a Live USB2. Mount root partition: sudo mount /dev/sdXn /mnt3. Chroot: sudo chroot /mnt4. Reinstall GRUB: grub-install /dev/sdX5. Update GRUB: update-grub6. Reboot: exit → sudo reboot
Need an Automatic GRUB Repair Tool1. Install Boot-Repair: sudo apt install boot-repair2. Run: boot-repair

Wrapping Up – Install GRUB on Ubuntu

GRUB is an essential element of the Linux boot process, which allows users to manage multiple operating systems and recover from boot failures. Regardless of the system you are using, configuring the right settings and troubleshooting issues is crucial for maintaining a stable system. 

1. What is GRUB in Ubuntu?

GRUB (Grand Unified Bootloader) is the default bootloader for Ubuntu and many other Linux distributions. It allows users to select between multiple operating systems and kernel versions at startup.

2. How do I reinstall GRUB after a system crash?

Boot into a Live Ubuntu USB, then run:
sudo mount /dev/sdXn /mnt # Replace Xn with your root partition sudo grub-install --root-directory=/mnt /dev/sdX sudo update-grub

3. What should I do if GRUB is missing or corrupted?

Use a Live Ubuntu USB, mount the partitions, and reinstall GRUB using grub-install and update-grub.

Marium Fahim
Hi! I am Marium, and I am a full-time content marketer fueled by an iced coffee. I mainly write about tech, and I absolutely love doing opinion-based pieces. Hit me up at [email protected].
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!