Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am a new ubuntu user and after accidentally formatting the boot partition I can't get it back to work. Here is some more info:

I was trying to format an sd card from the terminal and I accidentally may have formatted the partition which boots ubuntu. Now my computer goes directly to the BIOS settings and doesn't load the operating system. Under Boot tab in the Bios there is:

  • Launch PXE OpROM [Disabled]
  • Boot Option Priorities
  • Boot Option #1 [ubuntu (Drive not ....]
  • Boot Option #2 [ubuntu (Drive not ....]
  • Boot Option #3 [Windows Boot Manag....]

(I had removed windows long time ago.)

This is how I tried to solve the problem so far:

I created an ubuntu boot usb drive and was able to start the machine from the USB (luckily all the data was still there). I then tried installing ubuntu again alongside the old ubuntu. The installation completed successfully but the machine still won't boot without a USB drive.

I then followed the instructions in the thread for CreateBootPartitionAfterInstall

I tried running Boot-Repair but kept getting an error for a missing flag "bios_grub". So in gparted I changed the flag for my /dev/sda1 to bios_grub (it was "boot" before that - not sure if this was a right thing to do but couldn't run boot-repair without it). Here is what my partitions look like:

I ran boot-repair successfully but still to no avail - machine still wont' boot without the usb drive.

I then tried the advanced options in boot-repair and under the GRUB Location tab I checked "Seperate /boot partition sda1"

This also apparently went well and I received a successful boot-repair message at the end. The only problem there was that it couldn't run some updates on dev/sda6 and it instructed me to enable updates on the partition (which I have no idea how to do and thought that this was tangential to the main problem anyway). However, after restart I was back to the same problem - going straight to BIOS and still no boot.

The url from (the last) boot-repair is this:

I am now at a loss on what to do and how to get my machine back up. Any suggestions are greatly appreciated

share|improve this question
up vote 1 down vote accepted

You've been digging yourself into a deeper and deeper hole. Fortunately, I think you can still recover. Both to warn off others and to help you learn, I want to point out a few of your mistakes:

  • Re-installing Ubuntu because of a boot problem is almost always overkill at best, and runs the risk of destroying your user data at worst. You say that your data still exists, so you may have just wasted some time, but I want to point this out because it could have gone very badly, with lost user data to add to your boot problems.
  • Attempting to run Boot Repair from a BIOS-mode boot on a computer that was originally set up in EFI mode was a mistake. You probably didn't even realize you were making this mistake, but you did -- the fact that Boot Repair was complaining about the need for a partition with a "bios_grub flag" was a clue about this mistake. (This complaint from Boot Repair is clearly not very informative to anybody but experts, sadly.)
  • Changing the flag on /dev/sda1 from boot to bios_grub was a mistake. In parted and GParted terminology, the "boot flag" identifies an EFI System Partition (ESP), which is a partition that holds EFI boot loaders. A "bios_grub flag," OTOH, identifies a BIOS Boot Partition, which holds second-stage GRUB boot loader code for BIOS/CSM/legacy-mode boots. When you re-installed GRUB in BIOS mode, it overwrote the first few sectors of /dev/sda1, thus damaging the data on the partition. It sounds like your problems began with accidentally trashing this partition, so you probably didn't really do any more damage (except possibly to your /etc/fstab file), but this was definitely the wrong approach to take. If your problem had had a different cause, this mistake would have made recovery even more difficult.
  • Telling Boot Repair to treat /dev/sda1 as a separate /boot partition was also a mistake. You ended up telling it to treat that partition as two mutually exclusive things: as a separate /boot partition and as a BIOS Boot Partition. This could have messed things up even further, but it looks like it didn't really have much of an effect.

As further background on EFI booting, you may want to read my Web page on the subject, the Ubuntu community wiki on EFI booting, and/or Adam Williamson's blog explaining EFI issues. All three of these pages provide background information that may help you deal with this type of problem in the future.

As to the solution: There are several approaches, but I recommend you begin by fixing some of the problems that must be dealt with for any solution:

  1. Boot a Linux emergency disc.
  2. Use GParted or parted to change the "flag" on /dev/sda1 to boot. Alternatively, use gdisk to change the type code on this partition to EF00.
  3. Create a fresh FAT32 filesystem on /dev/sda1. You can do this with GParted or by using the command-line mkdosfs or mkfs utility.
  4. Mount /dev/sda6 and edit the /etc/fstab file on it. You must add an entry to this file to mount /dev/sda1 at /boot/efi. It should look like this:


/dev/sda1      /boot/efi   vfat        fmask=133       0 0

Alternatively (and preferably, in some ways), you can change /dev/sda1 at the start of that line to UUID="XXXX-XXXX", where XXXX-XXXX is the "UUID" (really a serial number) value for the partition, as reported by blkid. This value will only be valid after you've created a fresh FAT filesystem on the partition, so it's unknowable as I write this answer.

Once you've made these changes, you must install a fresh EFI-mode boot loader. Several choices are available. The two that are likely to be easiest to install are:

  • rEFInd -- You can install rEFInd by booting into Linux using whatever method works, verifying that /boot/efi is mounted, and installing the Debian package, available from the rEFInd downloads page.
  • GRUB 2 via Boot Repair -- The Boot Repair tool should re-install GRUB; however, you must run the program when booted in EFI mode. Check for the presence of a directory called /sys/firmware/efi. If it's present, you've booted in EFI mode and you can run Boot Repair. If it's not present, you've probably booted in BIOS mode and Boot Repair will be useless at best. If you've booted in BIOS mode, go into your firmware setup utility and disable BIOS/CSM/legacy support; or use your firmware's built-in boot manager to select a boot option that includes the string "EFI" or "UEFI." Unfortunately, I can't be more specific because firmware setup utility and firmware boot manager details vary so much from one computer to another.

It might be necessary to wipe the BIOS-mode GRUB code from the first sector of your hard disk. If you complete the repair and still can't boot from the hard disk, try booting to Linux and typing the following command in a Terminal:

sudo dd if=/dev/zero of=/dev/sda bs=440 count=1

Be very careful when typing that command; a slip-up, especially if you omit or specify the wrong value for bs= or count=, can do serious damage to your disk. That's why I didn't include this in the main recovery procedure.

Good luck!

share|improve this answer
Thanks for the detailed answer. I was able to successfully follow your instructions almost to the last step. However it seems that I am still booting to BIOS judging by the missing /efi folder. I also couldn't install the Debian rEFInd because it was incompatible with my system (i think because of the 64 bits - I couldn't find a 32 bit version). Deleting the GRUB code from the first sector also didn't seem to do anything. At this point I think I will just back up my data and reinstall ubuntu. Will this fix the problem? – gpanterov Feb 18 '14 at 15:41
If your installed Ubuntu is 32-bit, then it's puzzling to me how you ended up in the state you're in now. I didn't notice a mention of your computer make or model, but your Boot Repair output indicates your CPU is 64-bit-capable, and such systems should usually have a 64-bit Ubuntu installed on them, at least when booting in EFI mode. 32-bit installs on 64-bit EFI hardware are likely to be problematic at best. Please verify that you've actually got a 32-bit installation. If you re-install, I recommend doing it with a 64-bit Ubuntu. – Rod Smith Feb 18 '14 at 18:11

Judging from the screenshot, your boot partition seems unreadable. Try opening a live session and reformatting /dev/sda1, then running sudo grub-install /dev/sda, then sudo update-grub. That will reinstall your bootloader and should get you past the hang at boot.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.