You are on page 1of 31

How to Rescue, Repair and Reinstall GRUB

Boot Loader in Ubuntu


Matei Cezar Categories Ubuntu 6 Comments

This tutorial will guide you on how to rescue, repair or reinstall a damaged Ubuntu machine which
cannot be booted due to the fact that the Grub2 boot loader has been compromised and cannot load
the boot loader which transfers the control further to the Linux kernel. In all modern Linux
operating systems GRUB is the default boot loader.
This procedure has been successfully tested on an Ubuntu 16.04 server edition with the Grub boot
loader damaged. However, this tutorial will only cover Ubuntu server GRUB rescue procedure,
although the same procedure can be successfully applied on any Ubuntu system or on the majority
of Debian-based distributions.

Requirements
1. Download Ubuntu Server Edition DVS ISO Image
You try to boot your Ubuntu server machine and you see that the operating systems no longer starts-
up and you discover that the boot loader program no longer works?
Typically, the GNU GRUB minimal console appears on your screen, as illustrated on the below
screenshot. How can you restore the Grub in Ubuntu?
There are a lot of methods in Linux that can be used to re-install a broken grub, some can involve
the ability to work and restore the boot loader by using the Linux command line and others are
fairly simple and implies booting the hardware with a Linux live CD and using the GUI indications
to repair the damaged boot loader.

Among the simplest methods, that can be used in Debian based distributions, especially on Ubuntu
systems, is the method presented in this tutorial, which involves only booting the machine into the
Ubuntu live DVD ISO image.
The ISO image can be downloaded from the following link: http://releases.ubuntu.com/

Reinstall Ubuntu GRUB Boot Loader


1. After you’ve downloaded and burned the Ubuntu ISO image, or created a bootable USB stick,
place the bootable media into your appropriate machine drive, reboot the machine and instruct the
BIOS to boot into Ubuntu live image.

2. On the first screen, choose the language and press [Enter] key to continue.
3. On the next screen, press F6 function key in order to open the other options menu and select
Expert mode option. Then, hit Escape key to return to Boot Options line in editing mode, as
illustrated in the below screenshots.
4. Next, edit Ubuntu live image boot options by using the keyboard arrows to move the cursor just
before the quiet string and write the following sequence as illustrated in the below screenshot.
rescue/enable=true

5. After you’ve wrote the above statement, press [Enter] key to instruct the live ISO image to boot
into rescue mode in order to Rescue a broken system.
6. On the next screen select the language you want to perform the system rescue and press [enter]
key to continue.
7. Next, select your appropriate location from the presented list and press [enter] key to move
further.
8. On the next series of screens, select your keyboard layout as illustrated in the below screenshots
9. After detecting your machine hardware, loading some additional components and configuring the
network you will be asked to setup your machine hostname. Because you’re not installing the
system, just leave the system hostname as default and press [enter] to continue.
10. Next, based on the supplied physical location the installer image will detect your time zone.
This setup will accurately work only if your machine is connected to internet.
However, it’s unimportant if your time zone is not correctly detected, because you are not
performing a system installation. Just press Yes to continue further.
11. On the next screen you’ll be directly transferred into rescue mode. Here, you should choose
your machine root file system from the provided list. In case your installed system uses a logical
volume manager to delimit partitions, it should be easy to detect your root partition from the list by
reviewing volume group names as illustrated in the below screenshot.
Otherwise, in case you’re not sure which partition is used for the /(root) file system, you should
try to probe each partition until you detect the root file system. After selecting the root partition
press [Enter] key to continue.
12. In case your system has been installed with a separate /boot partition, the installer will ask
you whether you want to mount the separate /boot partition. Select Yes and press [Enter] key to
continue.
13. Next, you will be provided with Rescue operations menu. Here, select the option to Reinstall
the GRUB boot loader and press [enter] key to continue.
14. On the next screen, type your machine disk device where the GRUB will be installed and press
[Enter] to continue, as shown in the below image.
Usually, you should install the boot loader on your first machine hard disk MBR, which
is /dev/sda in most cases. The installation process of GRUB will start as soon as you hit the
Enter key.
15. After the live system installs the GRUB boot loader you will be directed back to main rescue
mode menu. The only thing left now, after you’ve successfully repaired your GRUB, is to reboot
the machine as shown in the below images.
Finally, eject the live bootable media from the appropriate drive, reboot the machine and you should
be able to boot into the installed operating system. The first screen to appear should be installed
operating system GRUB menu, as illustrated in the below screenshot.
Manually Reinstall Ubuntu Grub Boot Loader
14. However, if you like to manually reinstall the GRUB boot loader from Rescue operations
menu, follow all the steps presented in this tutorial until you reach point 13, where you make the
following changes: instead of choosing the option to reinstall GRUB boot loader, select the option
which says Execute a shell in /dev/(your_chosen_root_partition and press [Enter] key to
continue.
15. On the next screen hit Continue by pressing [enter] key in order to open a shell in your root file
system partition.
16. After the shell has been opened in the root file system, execute ls command as presented below
in order to identify your machine hard disk devices.
# ls /dev/sd*

After you’ve identified the correct hard disk device (usually the first disk should be /dev/sda),
issue the following command to install the GRUB boot loader on the identified hard disk MBR.
# grub-install /dev/sda

After GRUB has been successfully installed leave the shell prompt by typing exit.
# exit
17. After you’ve exited the shell prompt, you will be returned to main rescue mode menu. Here,
choose the option to reboot the system, eject the live bootable ISO image and your installed
operating system should be booted without any issue.
That’s all! With a minimal effort you’ve successfully rendered your Ubuntu machine the ability to
boot the installed operating system.
• Tags Recover Ubuntu Grub Post navigation
Impress Your Friends with This Fake Hollywood Hacker Terminal
Learn Linux System Auditing with Auditd Tool on CentOS/RHEL
If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any
questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should


Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles,
Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands
of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of
appreciation.

We are thankful for your never ending support.

Related Posts

How to Install UrBackup [Server/Client] Backup System in Ubuntu


How to Install XFCE Desktop in Ubuntu and Linux Mint

How to Install Ajenti Control Panel in Debian and Ubuntu


How to Install Latest Wine in Ubuntu Linux

How to Install Wine on Debian, Ubuntu and Linux Mint


How to Mount and Unmount an ISO Image in Linux

6 thoughts on “How to Rescue, Repair and Reinstall GRUB Boot Loader in


Ubuntu”

1.
Skip Flem
I have a quick grub2.02 display, however it’s ignored. and the computer boots straight to
‘line 1‘; despite a boot cd in the drive and a usb stick in a usb3 port. It’s as if the keyboard is
never recognized until I get my Ubuntu screen.
Reply

2.
ilyas
Does this affect files and data on my ubuntu or nothing at all and I will be able to retrive
them all?
Reply

3.
Doug Nintzel
Hello, thanks for the article. You mentioned in the intro “However, this tutorial will only
cover Ubuntu server GRUB rescue procedure, although the same procedure can be
successfully applied on any Ubuntu system or on the majority of Debian-based
distributions.” …
I don’t see these screens or menu options in non-server installs….how do you get to expert
mode and modify the parameters etc.?
Reply

4.
Mohammad
In below part of your post you said “before the quiet string” but the correct is “after the
quiet string“. please check it out.
4. Next, edit Ubuntu live image boot options by using the keyboard arrows to move the
cursor just before the quiet string and write the following sequence as illustrated in the
below screenshot.
Reply

5.
Julian
I think this information is not valid for modern SSD machines. In my system /dev/sda
(/dev/sda1) is an external hard disk. The internal hard disk from which the OS boots is
/dev/nvme0n1.
Reply


Alex
It’s valid if it’s SATA SSD.
Reply

Got something to say? Join the discussion.


Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind
that all comments are moderated and your email address will NOT be published.
A Beginners Guide To Learn Linux for Free [with Examples]
Red Hat RHCSA/RHCE 8 Certification Study Guide [eBooks]
Linux Foundation LFCS and LFCE Certification Study Guide [eBooks]

Linux Commands and Tools


4 Ways to Find Out What Ports Are Listening in Linux
Zaloha.sh – A Simple Local Directory Synchronizer Script for Linux
Assign Read/Write Access to a User on Specific Directory in Linux
21 Tar Command Examples in Linux
Add Rainbow Colors to Linux Command Output in Slow Motion
10 Interesting Linux Command Line Tricks and Tips Worth Knowing

Linux Server Monitoring Tools


How to Install vnStat and vnStati to Monitor Network Traffic in Linux
How to Do Security Auditing of Linux System Using Lynis Tool
How to Add Linux Host to Nagios Monitoring Server Using NRPE Plugin
Monit – A Open Source Tool for Managing and Monitoring Linux System
TCPflow – Analyze and Debug Network Traffic in Linux
Htop – An Interactive Process Viewer for Linux

Learn Linux Tricks & Tips


How to Set Static IP Address and Configure Network in Linux
Show a Custom Message to Users Before Linux Server Shutdown
Use ‘pushd’ and ‘popd’ for Efficient Filesystem Navigation in Linux
How to Set or Change System Hostname in Linux
5 Command Line Tools to Find Files Quickly in Linux
How to Add a New Disk to an Existing Linux Server

Best Linux Tools


5 Most Notable Open Source Centralized Log Management Tools
Best Command Line HTTP Clients for Linux
16 Best Web Browsers I Discovered for Linux in 2020
13 Best Tools to Access Remote Linux Desktop
The 10 Top GUI Tools for Linux System Administrators
16 Best Open Source Video Players For Linux in 2020
• Donate to TecMint
• Contact Us
• Advertise on TecMint
• Linux Services
• Copyright Policy
• Privacy Policy
• Career
• Sponsored Post

Tecmint: Linux Howtos, Tutorials & Guides © 2022. All Rights Reserved.
The material in this site cannot be republished either online or offline, without our permission.
Hosting Sponsored by : Linode Cloud Hosting

You might also like