1

I am running Ubuntu 15.04, installed on a 256GB SSD. There is no other operating system there - just a small boot partition, an ext4 partition with my data, and a swap partition.

A few minutes ago, I wanted to format a USB key with several partitions. Needless to say, I got confused and formatted the boot partition in my SSD drive as NTFS instead. (I chose the quick option, without data erasure.) Noticing what I had done, I formatted it as FAT (which I think it was before the accident). I then tried to reboot the computer, but it failed to reboot; it gave me a "No bootable devices found. Press F1 key to retry boot, Press F2 key, etc." message.

What can be done?

2 Answers2

2

You wrote:

Noticing what I had done, I formatted it as FAT (which I think it was before the accident).

If the partition was indeed FAT before the accident, then that suggests it was an EFI System Partition (ESP), which in turn implies you were booting in EFI mode. If this is correct, then recovery is relatively simple, and can be done in several ways, the easiest two of which are:

  • Boot to an Ubuntu live CD in EFI mode, install the Boot Repair tool, and run it. This should install a fresh copy of GRUB on your ESP and everything should start working again.
  • If Secure Boot is enabled in your firmware, disable it; then download the USB flash drive or CD-R version of my rEFInd boot manager, prepare a boot medium from it, and boot using it. rEFInd should give you options to boot your Linux kernel. Boot it. Once Linux is running, you can open a Terminal and either:
    • Install the rEFInd PPA or Debian package, as described on the rEFInd downloads page.
    • Mount your ESP at /boot/efi, then type sudo grub-install followed by sudo update-grub to re-install and configure GRUB.

Before you attempt either of these procedures, though, I recommend you check for existing kernels by mounting your Ubuntu root (/) partition and checking the contents of its /boot directory. If that directory is empty, then you have no kernels, which means the partition you overwrote was probably a Linux /boot partition and not an ESP. In this case, you must re-install your kernels. If you see a number of files, including ones with names that begin vmlinuz, then you did not overwrite a /boot directory and chances are you can recover your system with the either of the procedures I've just outlined.

If you need to recover your kernels, then the procedure is more complex, and I don't happen to have step-by-step instructions handy. It can be done, but it might be simpler to back up your personal files from the /home directory, re-install, and then restore your personal files.

Rod Smith
  • 45,120
  • 7
  • 66
  • 108
0

I'm to lazy to start a Live system, the following is from memory. ;)


Reinstall your system

  1. Boot a Live system
  2. Mount the / partition and backup the following folders: /etc, /var and maybe /opt
  3. If you have no separate /home partition, stop here and go to the the chapter Create a separate /home partition and follow the steps there
  4. Unmount all partitions
  5. Start the installation
  6. In the configuration steps you will see a question about partitioning, eg. something like "Use the entire HDD" and other options
  7. Select "Other"
  8. Define the positions for /, swap and so on and the partition for /home.
  9. For all partitions set format disk but not for /home.
  10. Finish the configuration and use you old username.
  11. Finish the installation
  12. After that you can restore some configurations from the /etc backup and so on

Create a separate /home partition

If there is no separate /home partition, than it's now time to create one.

  1. Backup your existing /home on an external drive
  2. Resize your partition with gparted
  3. Create a /home partition
  4. Move your data back
  5. Go back to the chapter Reinstall your system and continue with point 4
A.B.
  • 92,125