.shock - Fotolia

Help! I deleted a Linux boot partition

I deleted a partition on my Linux system, but I still see a boot menu. How do I re-install GRUB2 and not lose data?

Let's set the scenario: You've either accidentally deleted your Linux boot partition or an update went wrong and deleted it. Now you're unable to access your data.

Your best bet is to rescue the data -- using a Linux-based rescue disk -- and re-install or go into rescue mode, if the distribution allows, and repair.

There are plenty of methods to either repair GRUB2 or another Linux boot loader or recover data from a non-booting machine.

Let's examine how to repair the Linux boot loader by repairing GRUB2 on an Ubuntu desktop machine. You can do the repair through the graphical user interface or use the command line -- the graphical route is simple.

You must have the distribution's installation media on CD or USB flash drive. Boot the machine where GRUB2 is not functioning with this media. When prompted, click the button to try Ubuntu, not to install it. Once the live desktop is running, open up a terminal window by pressing [Ctrl][Alt][t] on the keyboard. When the terminal window is open, enter the following commands:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair

When prompted, enter your sudo password to continue. Once the installation is complete, run the Boot Repair tool with the command:

boot-repair

When the app runs, click Recommended Repair

Linux boot repair
Figure 1. Run the repair to restore your Linux boot partion

Once the boot repair is complete, reboot and you should be able to run the Linux machine with your data.

If repairing the boot partition doesn't work and you still don't have access to the data on the machine, there's more to try. There are Linux distributions geared specifically for such a task. Burn one of the ISO images -- an exact copy of a file system -- to a disk, boot the broken system with the newly created disk, locate the data with the distribution's file manager, and copy the data to an attached external drive.

Even if your Linux box is unable to boot, the data isn't lost. Either repairing your boot loader or using one of the data recovery distributions will save your information.

Next Steps

Fix Linux boot problems with GRUB

Linux boot options in RHEL, SLES with GRUB2

Guide to Linux troubleshooting

Dig Deeper on Data center ops, monitoring and management

SearchWindowsServer
Cloud Computing
Storage
Sustainability
and ESG
Close