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:
- Backup all your data from the external hard drive, possibly move it out of there.
- Download and burn Ubuntu live ISO on the external hard drive (not network installer).
- Boot from the external hard drive (boot into Ubuntu on your external hard drive).
- Install
boot-repair
utility, from terminal:
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install boot-repair
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.
Then, proceed with booting into Windows and from there, open Disk Management, while your external hard drive is plugged in.
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.
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:
- Plug your external hard drive in to the computer.
- Boot and enter BIOS Setup.
- 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.
- 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:
- 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.
- Boot into the live Ubuntu environment and open up your terminal.
- 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
.
- 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.