How to get rid of grub boot loader from external HDD

7,426

Solution 1

1. First of all login to BIOS and make sure that in your boot order the first drive is your primary system disk (not a USB bootable devices or CDROM). Depending on computer brand there also exist possibility to choose boot device on demand (usually by pressing F12 button) where you can choose boot device, in this case select primary hard drive instead of USB drive.
If it resolve your issue, follow steps 2,3 below to get rid of GRUB on external hard drive, otherwise Ubuntu installed GRUB on to your system disk, you need to follow @harrymc answer described in this tread to get rid of GRUB's bootloader from system disk.

2. If your external drive formatted as MBR then this step will remove GRUB's bootloader:
Run any Linux base LiveCD (SystemRescueCd is a good candidate) then erase bootloader
with dd command from terminal as

  dd if=/dev/zero of=/dev/sdX bs=446 count=1

Make sure to replace sdX with correct(!!!) drive that you want to treat.

With SystemRescueCd you can type startx, wait till desktop loaded then menu->system run "Show filesystem" to spot drive name where grub need to be deleted

3. If your external hard drive formatted as GPT, then you need to clear sector 1 (in zero based counting) where GPT keeps bootloader and partition table.

Or you can clear all booloader sections on external hard drive regardless if it MBR or GPT by using dd command described in step 2 as

# Clear everything. Make sure sdX is your external hard drive (!!!)
dd if=/dev/zero of=/dev/sdX count=1 bs=16MB

It will destroy partition table as well partition and its data, so be make sure to save files from external drive before doing this.

When you finished with removing GRUB's bootloader, go to Control panel->Administrative tools->Computer management and from the left panel select Storage->Disk management then select external hard drive, make a right click on it and finally format it.

Solution 2

As you have reformatted the external disk, your problem is not with it. Grub is therefore installed on your system disk, and is apparently set to boot first from the external disk and second from Windows.

What is happening now when you try to boot with the drive plugged in, is that Grub accesses the first partition on it, which supposedly contains the Ubuntu boot code, but finds instead a Windows partition probably formatted as NTFS that it cannot understand. It therefore gives the message of "error unknown filesystem". If the drive is not plugged in, Grub quietly boots from Windows.

Your problem is now the classical problem of undoing the dual-boot of Windows and Linux. You have two options : Either only delete the external disk as a boot option, or replace the boot code by the Windows bootloader. You of course also have the third option of never booting with the drive plugged in.

The simplest solution would be to use the free tool of Dual-boot Repair Windows 10, where "Automatic Repair" will fix the booting to Windows.

For only deleting Ubuntu as a boot configuration, see the Ask Ubuntu article
Uninstall Grub and use Windows bootloader.

For manually fixing the problem while booting from Windows, see for example this post:
How to fix the Windows 10 boot loader from Windows.

Solution 3

The fastest and most efficient way would be the third example I've given, if you're using legacy GRUB.

First example:
You cannot use Windows' fixmbr option, since there is no Windows running on your external hard drive. What you can try and do is use the Ubuntu Boot Repair utility with a live boot inside your external hard drive, to repair boot sectors:

  1. Backup all your data from the external hard drive, possibly move it out of there.
  2. Download and burn Ubuntu live ISO on the external hard drive (not network installer).
  3. Boot from the external hard drive (boot into Ubuntu on your external hard drive).
  4. Install boot-repair utility, from terminal:
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair
  1. Launch Boot Repair and use the Recommended repair option. This should fix the Master Boot Record on your external drive and remove GRUB from it.

  2. Then, proceed with booting into Windows and from there, open Disk Management, while your external hard drive is plugged in.

  3. Delete all your partitions on the external hard drive and re-format it. Make sure to properly erase all partitions and properly format it. Do not use quick format.

  4. Get all your files/data back into your external hard drive.

See related Q&A:
How to remove Ubuntu and put Windows on?


Second example:
I do hope this helps, however, why'd you need to boot while the external hard drive is plugged in? You can simply plug it in after boot.
Another option to fix this without trying to remove GRUB is:

  1. Plug your external hard drive in to the computer.
  2. Boot and enter BIOS Setup.
  3. Since you explained that you always get into grub rescue mode, that means that while your external hard drive is plugged in, GRUB takes priority in the boot process. Make Windows Boot Manager the first option to boot from or completely remove GRUB as a boot option. Since it is an USB external hard drive, this might be happening if boot from CD/USB is your first option as well.
  4. Save your settings and reboot.

This way you'll boot into Windows without problems even when your external hard drive is plugged in. GRUB existing in that drive should not be a problem.

See How to Disable Boot from USB or CD in BIOS Setup


Third example:
Note: The following works only for Legacy (MBR) GRUB. Do not use for EFI GRUB.

If those two do not help or do not satisfy your needs, there is another way.

GRUB Image Documentation states the following about the boot image of GRUB:

On PC BIOS systems, this image is the first part of GRUB to start. It is written to a master boot record (MBR) or to the boot sector of a partition. Because a PC boot sector is 512 bytes, the size of this image is exactly 512 bytes.

Thus, by overwriting the first 512 bytes of the external hard disk with zeros, you'd get a drive that is clean from a boot record or GRUB.

To do this:

  1. Download a live Ubuntu ISO and burn it onto your external hard drive, or if possible, on another USB drive. However, keep in mind that during the next steps, the external hard drive must be plugged in.
  2. Boot into the live Ubuntu environment and open up your terminal.
  3. Find the device corresponding to your external hard drive with via lsblk. If you're booting from the external hard drive, then its first partition should be mounted on /. Keep in mind that you need the path to the whole disk, not the partition, e.g. /dev/sdb, not /dev/sdb1.
  4. Overwrite the first 512 bytes:
sudo dd if=/dev/zero of=[path_to_external_hard_drive] count=1

This will copy 1 block (count=1) from the /dev/zero file and will write it to the path specified after of=, which has to be your external hard drive. It will start from the beginning sector. On most versions of dd, the default block size is 512 bytes, thus we don't need to specify it. However, if you want to be safe, you can specify the block size using bs:

sudo dd if=/dev/zero of=[path_to_external_hard_drive] bs=512 count=1

bs specifies the block size in bytes. /dev/zero is a file that contains infinite amount of 0 characters (from wikipedia):

/dev/zero is a special file in Unix-like operating systems that provides as many null characters (ASCII NUL, 0x00) as are read from it.

So, the command will copy 1 block of 512 bytes from /dev/zero (meaning 1 block full of zeros) and will write it to the specified path. If we assume that /dev/sdb is your external hard drive, then here is a full example of the command (do not use /dev/sdb unless you are sure that it is the external hard drive):

sudo dd if=/dev/zero of=/dev/sdb bs=512 count=1

In this case, you do not need to re-format your external hard disk, you do not need to move the files out, however, there is a chance that file corruption might occur, thus it is suggested to still make a backup of your data. If file corruption occurs, then you might have to re-format the external hard disk again. However, after doing this, your disk will be free from any MBR/GRUB.

Share:
7,426

Related videos on Youtube

Jacob
Author by

Jacob

History I was born at 1998 in Czech Republic. Sadly at the age of 5, I was diagnosed with Asperger syndrome what explaining my poor social abilities. People like me are marked as "retards" and no one IT school wants accept me. I wanted to show them how terribly they were wrong in me, not only in me but in other people like myself. At the age of 12, I started working with a tool called Game Maker, and at the age of 15 I started to learn the C # programming language. When I was 16, I finished my first game that I could not publish due to the copyright of the music used in the game. In autumn 2017, I finished the first public game named War City. Character Mealchonic introver with a high level of intelligence but very weak social capabilities. I always liked anime and manga, I also like nightcore. I do not care what other people think about me and I will always do what I like, regardless of the opinion of others. I love old games, especially games for GameBoyAdvanced or PlayStation1 also I like games from the late DOS era and the early Windows era. These old games have something that is missing in the new games, something indescribable, something like.... soul.

Updated on September 18, 2022

Comments

  • Jacob
    Jacob over 1 year

    For a while, I tried Linux Ubuntu as my OS. Like any OS, Linux has its drawbacks, some of which are a big issue for me. So I went back to Windows 7.

    To prevent modifications to my system while I was trialling it, I installed Ubuntu on an external HDD. I was using this drive as a portable work-space, so on it I also installed GIMP, Aseprite, Audacity, PixiTracker, SunVox, the GoDot game engine and some video games, all bound together by the PortableApps.com platform.

    When I removed Ubuntu from the drive, I performed many steps, including a full re-format. But now, when I try to start my computer with the drive plugged in to a USB port, I get this

    error unknown filesystem entering rescue mode
    

    Looking into the drive, I only found one partition, which is neither system nor boot. So there is no trace left behind on it, but Grub somehow remembers the previous installation.

    Does anyone know how to get rid of it? I read recommendations to use a tool to replace Grub with the Windows boot loader, but I don't want to have any boot loader on my external HDD.

  • Fanatique
    Fanatique almost 6 years
    Oh.. was just adding that scenario, guess you sniped me :)
  • Alex
    Alex almost 6 years
    No, I didn't and Im not a telepathic :)
  • Fanatique
    Fanatique almost 6 years
    I know, was saying it in the good way. However, why using a block size of 446 bytes? On the classical generic MBR, yes, this would overwrite the bootstrap code area and will leave the partition table. However, on any other MBR structures (see Sector layout), this might not work, or at least not completely. I also doubt that we'd need the partition table in MBR if OP won't be using it as a boot drive anymore, just as he has stated.
  • Alex
    Alex almost 6 years
    Some "oversmarted" program can use space behind first two octets, so safly to keep it as it is
  • fixer1234
    fixer1234 almost 6 years
    Grub is on the primary drive. After removing it, won't you need another step to reinstall the Windows bootloader?
  • Alex
    Alex almost 6 years
    Yes, that what I suggested in comments under OP question, I thought that OP installed Ubuntu on external drive and loaded it on demand without touching primary drive, but it looks like he installed it while primary drive was active and Ubuntu installed GRUB's loader on primary drive. I think that "harrymc" described how to do that in his answer very well.
  • Fanatique
    Fanatique almost 6 years
    @Alex why do we have to assume that he has installed in on the primary drive? In the current situation, GRUB enters rescue mode because of the lack of a root Linux partition, since it's removed. However, OP has mentioned, that it does that only when the external HDD is plugged in. If it was on primary partition, that would happen all the time since there is no Linux, not just when external HDD is connected.
  • Alex
    Alex almost 6 years
    @Fanatique If bootloader cleared on external HDD then the only place where GRUBS' rescue mode fired up is the system drive. You gave me idea that possibly in BIOS boot order the first drive are USB devices instead of system drive so this will explain this mystery. I updated my answer.