0

Installed Linux on external HDD. Now I cannot boot Windows 10 without my HDD being plugged in. And I have to boot from the HDD first, to get to Linux grub, to select to boot to Windows 10.

I want to be able to boot Windows 10 without needing my HDD plugged in, and without having to go through Linux grub.

Any questions just feel free to ask.

Any other thread that has the answer to this feel free to link it.

big i
  • 1
  • It looks like you installed Ubuntu on the external drive but grub on the internal drive. – user68186 May 15 '18 at 22:26
  • 2
    Really need to know if UEFI or BIOS, fixes are different. If UEFI you can just boot Windows from UEFI boot menu. If BIOS you have to install grub to external drive and reinstall Windows boot loader to internal drive. Post this: sudo parted -l Partitioning will usually show which way you are booting. – oldfred May 15 '18 at 23:02
  • If any of the answers worked for you, consider marking it as the correct answer by clicking on the green check mark on the left margin of that answer. This will help others with similar problems. – user68186 May 18 '18 at 15:32

3 Answers3

1

Two part solution:

Part 1: Remove Ubuntu entry from the EFI partition in the internal disk

See: How do I remove "Ubuntu" in the bios boot menu? (UEFI)

Step 1: Boot Ubuntu from a Live DVD/USB in UEFI mode and select Try Ubuntu without installing option.

Step 2: Open a terminal by Ctrl+Alt+T and install efibootmgr:

sudo apt-get install efibootmgr

Step 3: Then add to the kernel efi support

sudo modprobe efivars

Step 4: Then run sudo efibootmgr to check your boot entries. It will return something like this:

BootCurrent: 0004
Timeout: 2 seconds
BootOrder: 2001,0003,0005,0006,0000
Boot0000* Lenovo Recovery System
Boot0001* EFI Network 0 for IPv6 (B8-88-E3-84-F3-EF)
Boot0002* EFI Network 0 for IPv4 (B8-88-E3-84-F3-EF)
Boot0003* Windows Boot Manager
Boot0004* EFI USB Device (SanDisk)
Boot0005* ubuntu
Boot2001* EFI USB Device

Step 5: Then delete the option you dont want. In this example, Ubuntu is entry 5. the following could be called to delete entry 5 and remove it from the BootOrder.

(CAUTION: Before executing the following command make sure you enter the correct Boot entry number)

sudo efibootmgr -b 5 -B 

Step 6: Delete the Ubuntu folder in the EFI partition.

Suppose your EFI partition was /dev/sda2, then mount it on an empty folder anywhere.

sudo mkdir /mnt/efipart
sudo mount /dev/sda2 /mnt/efipart

Now we have to find the directory Ubuntu or any other distro's name in this partition. It is mostly under EFI/distro_name.

Remove that directory and its contents by (PLEASE MAKE SURE YOU ARE DELETING THE CORRECT DIRECTORY)

sudo rm -r ubuntu

This ends Part 1. This is a good time to

Check if it worked

Shut down the computer and disconnect all external drives and remove the Live DVD if you were using one. Start the computer. If all went well, It should directly boot Windows 10 as it did before installing Ubuntu.

Part 2: Fix grub and EFI in the External hard drive where you have Ubuntu

See Is it still possible to install Ubuntu to an external harddrive with UEFI?

Step 1: Again boot Ubuntu from a Live DVD/USB in UEFI mode and select Try Ubuntu without installing option.

Connect the external hard drive with Ubuntu you want to fix. Note down the drive name. Here I will assume it is /dev/sdc, but yours may be different.

Step 2: Install the grub-efi-amd64-bin package.

sudo apt install grub-efi-amd64-bin

This will only install the resources needed. It will not switch your existing MBR style installation to UEFI and turn things upside down.

Step 3: Shrink your Ubuntu partition in GParted to make space for an ESP. Recommended sizes for ESPs range from 100 MB to 500 MB. I made around 250 MB.

Note: It shouldn't matter where your ESP is located on the disk and shrinking your Ubuntu partition by a few megabytes from the end should be quick and safe. Shrinking at the beginning is not safe.

One caveat though, your ESP should be a primary partition and not be part of an extended partition or a logical volume, partition numbers from 1 to 4 are fine, numbers above indicate an extended partition on MBR partition tables.

Choose FAT32 as filesystem and set the boot flag.

Step 4: Mount the ESP partition you just created and the root file system you shrunk.

sudo mkdir -p /mnt/esp
sudo mount /dev/sdc3 /mnt/esp
sudo mkdir -p /mnt/rootfs
sudo mount /dev/sdc1 /mnt/rootfs

Note: In this example, /dev/sdc3 is the ESP partition and /dev/sdc1 is the root partition. Yours may be different. The mountpoints /mnt/esp and /mnt/rootfs are just examples chosen to work with the remaining part of this answer.

Install GRUB's EFI image and a minimal configuration file with:

sudo grub-install --efi-directory /mnt/esp --boot-directory /mnt/rootfs/boot --target x86_64-efi --removable /dev/sdc

Step 5: Check and update /etc/fstab file using the following command:

sudo nano /etc/fstab

Your UEFI installation of Ubuntu may include a line similar to the one below in /etc/fstab.

UUID=1234-567F /boot/efi vfat defaults 0 1

where 1234-567F is an example. If such a line exist, find the UUID of your new EFI partition in the external drive using Gparted or with the command sudo blkid. Update the UUID in the file and save and exit the nano editor with Ctrl+X followed by Y and Enter.

That is it. Now the external drive should boot.

Hope this helps

user68186
  • 33,360
  • Isn't it necessary to adapt /etc/fstab on the external drive then to mount the correct ESP? Please check the last command too, it looks like the syntax is not correct, missing a few ='s. – mook765 May 16 '18 at 00:09
  • I think editing fstab is necessary, not for the installation of the grub-images but for the future. When upgrading the system installs a new version of Grub it would install the grub-images in the wrong ESP if we didn't adapt fstab. Anyway, your answer describes a nice way of installing grub-images without chrooting into the installation, I have never seen this before, thumbs up! – mook765 May 16 '18 at 12:42
  • @mook765 Thanks again. I have edited the fstab section substantially. – user68186 May 16 '18 at 12:46
0

For a UEFI installation:

  1. Assuming you put an EFI partition on the external hdd, just copy the entire internal EFI to the external disk's EFI partition. That allows the external disk to boot, with grub,which can then select Ubuntu or Windows.
  2. Alter the boot preference order to external hdd first, Windows second. When the external disk is not present, Windows will boot.

Don't even bother to try to remove the /EFI/ubuntu on the internal disk, consider it a backup, it wont be running in any case.

ubfan1
  • 17,838
0

Seems that you have choosen your external HDD to install bootloader (Grub) . So , i think , you need to reinstall . No necessary to format your partitions but choose a different partition to install GRUB.

E_Angel
  • 291