2

I'm trying to install an Ubuntu dual boot on my windows 10 laptop. Windows 10 used the legacy BIOS setting.

When I start the Ubuntu installation I get a warning about BIOS and UEFI, other operating systems becoming unbootable, only proceed if sure, etc. But since no alternative is offered (other than simply giving up and not installing Linux) I decided to proceed, and found that after install, GRUB only offered a Linux option.

Is there a way for me to boot from Windows again? I don't mind to uninstall ubuntu

2
  • 3
    This is really a windows question.. But which Windows? Do you know if windows was booting from Legacy or UEFI? Under Linux do try sudo update-grub Apr 2, 2019 at 9:02
  • Windows is booting from legacy and it's windows 10
    – Azhar
    Apr 4, 2019 at 8:00

3 Answers 3

10

Depending on exactly what the warnings said, and what exact choices you made when installing Ubuntu, the installation process may have done one of a few things:

  • It may have converted the partitioning from MBR to GPT style to install UEFI-style, keeping (or resizing) the existing partitions. This is the best option: you'll just need to install a UEFI-style bootloader and you can then get back to Windows. Once the Windows UEFI bootloader is on the disk, Ubuntu might even detect it automatically the next time you run sudo update-grub and add it to the GRUB boot menu for you.

  • It may have just set up a UEFI-style bootloader on a MBR-partitioned disk. This is a problem, since while Linux can do this, Microsoft says Windows won't support this combination. However, returning to legacy-style Windows-only boot should be fairly easily doable in this case.

  • It may have taken the entire disk for Ubuntu, so your Windows installation was overwritten and no longer exists. This is the worst-case scenario: if you want Windows back, you'll need to fully reinstall it and your existing Windows files will be gone.

Identifying your situation

In Linux, run sudo fdisk -l /dev/sda. If your system disk is something other than /dev/sda, replace that with the appropriate device name. For example, on a new system with a NVMe SSD, it might be /dev/nvme0n1 instead.

The output should look similar to this:

$ sudo fdisk -l /dev/sda
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2B05CCE8-92BC-4308-B770-174CE63D044F

Device       Start       End   Sectors  Size Type
/dev/sda1     2048   1050623   1048576  512M EFI System
/dev/sda2  1050624   1550335    499712  244M Linux filesystem
<... other partitions listed here...>

If your version of Linux fdisk isn't too old, the output should include a line that says either

Disklabel type: gpt

or

Disklabel type: mbr

This identifies the partitioning style that is currently in use on your system disk.

GPT-partitioned system disk - installing a Windows UEFI bootloader

Since the Linux installer has set up a UEFI bootloader for us, there should also be an EFI system partition (ESP for short) on the disk. In the fdisk -l output, it is the partition that has its Type listed as EFI System and its size would typically be something in between 100M and 512M. In Linux, it might be mounted at /boot/efi. You might want to run sudo ls -l /boot/efi or take a peek at it with some GUI file manager so that you'll recognize the contents of this partition - you'll be seeing it at Windows command prompt for a bit. Typically, if ESP is mounted at /boot/efi, there should be a sub-directory like /boot/efi/EFI/ubuntu that contains the actual UEFI bootloader of Ubuntu.

Now, get yourself a Windows 10 installation media. You won't need the license code. Boot your computer from that installation media. Since your Ubuntu installed in UEFI mode, your computer will probably boot the Windows installer in UEFI mode automatically too, but in case you see two boot options for the installation media, only one of those options boots it in UEFI mode, and that's the one you should pick. (Hopefully the boot menu will say which is which - it depends on your system's UEFI firmware.)

When the Windows installer displays the initial screen with an "Install now" button in the middle of the screen, select instead "Repair your computer" near the bottom.

From the next menu, choose "Troubleshoot" and then "Command Prompt".

Now, type in these commands:

diskpart
list vol

This should display a list of partitions. Find the partition that has FAT32 in the "Fs" column - it should be your ESP you saw in Linux before. Note its volume number (Volume ### in the leftmost column) and assign an unused drive letter (like X:) for it. For example, if ESP is listed as Volume 2:

sel vol 2
assign letter=x:

It should say DiskPart successfully assigned the drive letter or mount point. at this time. Then type exitto quit the DiskPart utility.

Switch to the EFI directory on the ESP:

cd /d x:\EFI
dir

If you see the ubuntu directory, you're in the right place.

Now create a directory or two for the Windows UEFI bootloader:

mkdir Microsoft
cd Microsoft
mkdir Boot
cd Boot

Install the Windows UEFI bootloader to the ESP and re-create the Windows BCD registry:

bcdboot c:\Windows /l en-us /s x: /f UEFI /addlast

If you want the Windows bootloader to use a language other than English, replace en-us in the command above with the appropriate Windows language code.

Now type exit, remove the Windows installation media and reboot your system. It should come up in Ubuntu just as before. Run sudo update-grub to update the GRUB boot menu. If all goes well, it should now auto-detect the presence of UEFI Windows bootloader and add it to the GRUB boot menu.

Also now in the BIOS boot order menu, there should be a item named "Windows Boot Manager". If you want to remove Ubuntu and go back to Windows-only system, just switch this one as the primary boot option, and the system should skip GRUB and boot into Windows by default. Then you can remove the Linux partitions using Windows Disk Management. Do not remove the EFI System partition, as now Windows also needs it for booting.

(Work in progress - I'll add the MBR restoration option later)

4
  • 4
    Mine shows Disklabel type: dos
    – Mohsin
    Nov 6, 2019 at 13:28
  • c:\windows isn't a directory for me, neither was it a root directory in the iso what am I missing?
    – donkey
    May 12, 2020 at 17:06
  • Works 100%.Thanks.In my case,the efi partition was already listed as F drive .so used it instead of naming it a separate letter like X
    – U R
    Jul 24, 2021 at 17:19
  • My hero. Botched windows when installing arch linux, so glad a I didn't have to reinstall windows.
    – cajomar
    Jan 26, 2022 at 3:57
0

Okay so this definitely remains a windows question and really belongs on superuser.com or similar.

However in the interests of being helpful: from what you've written it sounds like the installer has changed the system of recording partitions on your hard disk. Your Windows boot loader was stored in the MBR (the first sector on the hard drive) along with the size and positions of your partitions.

In order to install as UEFI, the installer has rewritten the size and position of your partitions in GPT format completely overwritten the MBR in the process. This wasn't an accident. The two partition tables cannot co-exist and this was a necessary step. IE: this is what you were warned about.

I am not a windows expert, this is a linux forum. But I guess from here you basically have two options:

  1. Fix forward (try to install a windows EFI boot loader)
    • In theory, this might be possible as UEFI just needs the Windos boot loader installed in your (new) EFI partition
    • I have personally had problems getting windows to boot from an Ubuntu-created EFI partition so no guarantees here.
  2. Try to reverse out (try to revert back to MBR)
    • This is tricky and dangerous and still requires you to seek help from windows forums
    • In theory you could note down the details of your partitions and try to replace GPT with MBR containing the same partitions
    • Get this wrong and you could lose all your data so think very carefully before you try this.
    • Once you've replaced the partition table you would then need to re-install the windows bootloader to your MBR (out of scope for this forum and I don't know how)

As I say. From here try searching the web and asking on Superuser.com for windows specific instructions.

1
  • Thank you for your information
    – Azhar
    Apr 5, 2019 at 11:19
0

The problem usually lies from the fact that your machine's BIOS, the software that is entered with a special key, such as F2 or ESC while the machine is starting up, has been changed by the installation of the new operating system. The BIOS has a list of boot partitions, and in your case, Linux seems to have put itself up front. You can change it by going into your machine's BIOS and changing the boot order.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .