Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 400  / 1 Year ago, tue, march 21, 2023, 7:24:13

There seems to be a lot of questions on askubuntu and info on the web on how to install Ubuntu and Windows in dual boot, but everywhere Ubuntu is installed afterwards. I would like to install Windows on the system which is already running Ubuntu. It uses UEFI and has free space on HDD so it is possible to arrange a partition for Windows without much trouble. On MBR based systems it was possible as long as you copy MBR and restore it after Windows installation. Is it possible on a UEFI system? Will I have any problems?


More From » dual-boot

 Answers
0

It's possible, and if you know what you're doing, it's easier than recovering from the same situation with BIOS. Under EFI, boot loaders don't live in the MBR; they live in the EFI System Partition (ESP) as ordinary files. Therefore, the Windows boot loader won't overwrite the Ubuntu boot loader (GRUB 2, unless you install something else yourself), and there's no need to write a fresh copy to disk.



What Windows will do, though, is to save its own boot loader to the ESP and then make it the default. Unfortunately, the Windows boot loader doesn't offer the option to chainload to Linux, so the result can look very similar to the result under BIOS. Under EFI, though, you have more, and in some ways easier, solutions:




  • You can type, in a Windows Administrator Command Prompt window, bcdedit /set {bootmgr} path EFIubuntugrubx64.efi to restore GRUB as the default boot loader. (If you're booting with Secure Boot active, you may need to change grubx64.efi to shimx64.efi.)

  • You can boot a Linux emergency disk in EFI mode and use efibootmgr to restore GRUB to its primary position. You'll need to type efibootmgr alone to get a list of installed boot loaders, then change their order with the -o option to efibootmgr, as in efibootmgr -o 2,5,3 to boot Boot0002 first, then Boot0005, then Boot0003. (EFI tries each in turn until one works.)

  • The EFI version 2 shell has a tool called bcfg that can do what bcdedit and efibootmgr can do. See here for some instructions on installing rEFInd with an EFI shell. Steps 12-14 are critical and can be adapted for restoring GRUB to the primary boot program.

  • The better EFIs let you change the boot order in their firmware setup utilities. Unfortunately, details vary from one to another, and many lack this functionality.

  • You can hit a function key (which one to use varies between computers) to get the built-in EFI boot manager, which usually enables you to pick between Windows and Linux. This might be acceptable in your position if you'll usually be booting Windows, but it will get tedious if you often have to boot Linux.

  • You can install another boot loader of your choice -- as that page details, there are several options.

  • You can run Boot Repair from a Linux emergency disk. This usually fixes things up, but I'd reserve it as a last-resort tool because it's a pretty blunt instrument and it occasionally makes a hash of things.



Note that if you restore GRUB, you'll probably have to run update-grub to get it to detect Windows; otherwise you'll have traded a boot-straight-to-Windows situation in favor of boot-straight-to-Ubuntu. (One of Boot Repair's advantages is that it takes care of this -- at least, when it works correctly. My own rEFInd boot manager should auto-detect both OSes, too.)



So in sum, you've got a plethora of options. Using bcdedit in Windows followed by an update-grub in Linux is a pretty painless solution once you know about it.


[#24746] Wednesday, March 22, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
amelican

Total Points: 162
Total Questions: 116
Total Answers: 108

Location: Guam
Member since Mon, May 29, 2023
12 Months ago
;