0

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?

vehsakul
  • 103
  • 1
  • It certainly is doable. Have a look at this and this. You'll probably need to reinstall GRUB and possibly run boot-repair to reconstruct the dual boot configuration. – hmayag Jun 08 '14 at 14:09

3 Answers3

1

You may need to repair your grub loader, using a few simple steps from the official ubuntu wiki

https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows

nicandris
  • 399
  • 3
  • 9
  • 1
    You may want to change your answer slightly to indicate that "You are likely to have to repair your ubuntu installation using this official wiki...... It might be clearer what you mean. – Elder Geek Jun 08 '14 at 14:29
1

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 \EFI\ubuntu\grubx64.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.

Rod Smith
  • 44,284
  • 7
  • 63
  • 105
  • This is pretty much what I was looking for. Thanks a lot! The question basically was: what Windows will do "wrong" that I need to change (and how)? – vehsakul Jun 09 '14 at 09:55
  • BTW, I've read your answer and this one. What confuses me is that my system has grub_bios partition and, as pointed out in the second answer, the existense of /sys/firmware/efi is an indication that a computer boots in EFI mode. If it boots in EFI mode, does it need this partition? Is it just de bene esse in my case? Could you clarify this? – vehsakul Jun 09 '14 at 10:41
  • The BIOS Boot Partition is used, as the name implies, in a BIOS-mode boot. It is not used when booting in EFI mode. The presence of /sys/firmware/efi means that your computer has definitely booted (that time) in EFI mode. The BIOS Boot Partition might be present because of an earlier BIOS-mode installation or because it was created manually. Note that /sys/firmware/efi is a virtual directory; it's created by the kernel each time you boot. The BIOS Boot Partition, by contrast, is fixed; once created, it remains in place until you delete it. – Rod Smith Jun 09 '14 at 11:32
0

Unless your PC is very low on resources e.g. RAM, try e.g. Virtualbox instead and run the OS'es in parallell.

It makes it possible to e.g. Cut and Paste from each to the other (install "guest additions" in the guest OS, check the menu as the you have the guest OS running).

Hannu
  • 5,374
  • 1
  • 23
  • 40