In this case, do I need to make any changes to my HDD (windows) drive? IMO, If I boot from live USB and install ubuntu with grub on the M.2 drive, I should be able to boot into Windows or Ubuntu by just selecting the boot drive at boot without making any changes to any of the bootloaders. Also, can anyone confirm if I'll need to UEFI and/or secure boot for this much also?

  • If your both operating systems are in UEFI then both will boot, make sure that you have "EFI" partition at the beginning of the disk. And if their is a option in UEFI /Bios like "boot windows operating system only" then disable it. Newer Asus and gigabyte mother board have that option. This is not a definitive answer, any number of problems can arise while performing dual boot, but most of them are fixable – Sumeet Deshmukh Apr 2 '17 at 5:46
  • There is no "boot windows OS only" option, so that's okay. I'll make an EFI partition on the SSD, that should work. Thanks for your help @SumeetDeshmukh – Ankur A Sharma Apr 2 '17 at 7:01
  • No. it shouldn't. If Windows has been installed in UEFI mode (all factory installed are) then there's already an EFI partition and only one is required. The Ubuntu installer, if properly booted in UEFI mode, should use that EFI regardless of its location being in a different drive to where you're installing Ubuntu. – user589808 Apr 2 '17 at 10:05

I should be able to boot into Windows or Ubuntu by just selecting the boot drive at boot

This comment reveals a fundamental misunderstanding of the way modern EFI-based computers boot, and this misunderstanding is likely to lead you into problems in the future. Specifically, whereas older BIOS-based computers booted by reading boot loader code from the first sector (aka the Master Boot Record, or MBR) of a hard disk, and could be told to boot from a specific disk, EFI-based computers boot by reading boot loader files from one or more EFI System Partitions (ESPs). The computer must be told what files are boot loaders, though, and this information is stored in NVRAM. A single ESP can hold multiple boot loaders, and in fact a typical multi-boot configuration places all the OSes' boot loaders on one ESP. (That said, multiple ESPs, either on one disk or on multiple disks, are permitted.) See Adam Williamson's blog entry on how EFI works for more on this subject.

install ubuntu with grub on the M.2 drive

Note that the ESP must be readable by the EFI. Some computers' EFIs can read hard disks but not NVMe or M.2 disks. There's no way of knowing whether this will be true for your computer. If it is, you'll have to put your boot loader on the regular disk. Chances are you'll also have to boot your Linux kernel from the regular disk, too, meaning you'll need to put a /boot partition on that disk. This isn't certain, though; if your firmware can read your M.2 disk, then you'll be fine with a separate ESP and/or the Linux kernel on that disk.

One big caveat is this: The Ubuntu installer ignores any hints you might give it about where to install GRUB in EFI mode. It will install to the ESP on whatever it identifies as the first disk (if it has an ESP). Thus, if you want to put GRUB on an ESP on the M.2 disk, and if the Ubuntu installer identifies that disk as the second one, you'll have to jump through some extra hoops to get what you want. Two possibilities are:

  • You can launch the Ubuntu installer in "try before installing" mode, open a Terminal window, and type ubiquity -b. This will launch the installer but tell it to not install GRUB. You'll probably have to manually partition the M.2 disk, either before running ubiquity or as part of its operation, and create an ESP. When you're done, you can edit /etc/fstab in the installed system to mount the ESP on the M.2 disk at /boot/efi. You'll then have to install GRUB by using Boot Repair or by doing it manually. Alternatively, you could install my rEFInd boot manager or some other boot loader.
  • You can install normally (but you'll probably have to partition manually, as before) and let GRUB install to the ESP on the first disk, then boot into the installed system. Once you've booted, you can edit /etc/fstab, unmount the first disk's ESP, mount the M.2 disk's ESP, and re-install GRUB by typing sudo grub-install. This should get GRUB installed to the M.2 disk. A copy will still reside on the first disk, but it shouldn't do any harm.

OTOH, it's possible that the Ubuntu installer will identify the M.2 disk as the first disk, in which case no extra hoop-jumping will be required. Given the hassles of working around this, IMHO it makes the most sense to just let the installer put GRUB where it wants to and live with it. I can understand the desire to have "pristine" Windows and Ubuntu disks, but the effort required to achieve this goal is significant, particularly if you don't fully understand the EFI boot process and your firmware's capabilities.

One more caveat: Windows 8 and later turns its shutdown operation into a suspend-to-disk operation. This has the effect of trashing filesystems, including the ESP, when you multi-boot. You should be sure to disable Fast Startup and disable Hibernate in Windows to avoid these problems. This is true no matter where you install GRUB.

Also, can anyone confirm if I'll need to UEFI and/or secure boot for this much also?

If Windows 10 came pre-installed on the computer, then it almost certainly boots in EFI mode. See this page of mine for information on how to determine the Windows boot mode with certainty. The preceding (and following) paragraphs assume that your Windows is booting in EFI mode.

As a general rule, it's best to install all your OSes so that they use the same boot mode (BIOS/CSM/legacy vs. EFI/UEFI). Mixing boot modes is often possible, but it's always limiting and it usually requires jumping through extra hoops for both installation and boot loader configuration, and often for boot loader use.

If the computer ships with Windows 10 booting in EFI mode, it almost certainly also uses Secure Boot. In most cases, Ubuntu works fine with Secure Boot active, so this should pose no problems. If you think Secure Boot is causing problems, you can disable it and Windows will continue booting; however, based on various forum posts I've seen, I believe that many people are far too quick to blame problems on Secure Boot. To be sure, it can cause problems, but for a relatively simple installation like yours, IMHO it's best to leave it enabled, at least initially.

So, to recap, you can set up Ubuntu with GRUB on either the ESP that Windows created or an ESP on your M.2 disk, with the caveat that the latter might not work if your firmware can't read the disk, and it may take a lot of hoop-jumping to get GRUB to install on the M.2 disk. Either way, if everything works correctly, GRUB will take over as the default boot loader, and you should be able to use GRUB to select which OS to boot. Alternatively, you should be able to use the computer's built-in boot manager to select between GRUB (it will be called ubuntu in the menu) or Windows.

  • That's really helpful. I have only one device at the moment so I don't want to mess with my ESP at present. In this case, installing ubuntu with grub from a virtual machine using 'EFI boot on' as parameter should work I hope. A new ESP will get created on the M.2 drive. What do you think? – Ankur A Sharma Apr 3 '17 at 18:08
  • Your question refers to both a hard disk and an M.2 disk. Both are disks for all practical purposes, with the caveat that the EFI might or might not recognize the M.2 device. Most virtualization tools support EFI-mode booting, although some have limitations that can be important. – Rod Smith Apr 3 '17 at 19:06

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.