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?
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
ubiquityor as part of its operation, and create an ESP. When you're done, you can edit
/etc/fstabin 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.