[SOLVED] Make Windows 10 M.2 PCI SSD bootable

eddified

Distinguished
Jul 20, 2013
43
3
18,545
Hello, I have accidentally installed windows 10 in such a way that windows 10 is installed on my M.2 PCI SSD (which is desired), but the bootloader is installed on a SATA HDD (not desired). (This strange setup was accomplished by Windows 10 also being installed on the SATA HDD. As a result, the bootloader always asks me which instantiation of Windows 10 I want to boot.) The M.2 PCI SSD therefore has only one partition, which has windows 10 installed on it. How can I create room (at the start of the drive, I presume) on the M.2 PCI SSD, and install a EFI bootloader on the drive, without having to re-install windows? (Goal being to be able to remove the SATA HDD and still boot the system). I'm confident I can re-arrange the data and make room, but not necessarily at the start of the device. And not sure how to make it bootable. (Can the bootable partition be at the end of the drive, by any chance?)

(I'm guessing GParted is a good place to start for shrinking the win10 partition and making space for a new UEFI partition at the start of the drive)

TL;DR:
How to shrink the windows 10 partition on M.2 PCI SSD and create a bootable UEFI drive at the start of the device?
 
Solution
OK here is what I did to get it to work
1) Burn GParted live ISO to usb, and boot from it
2) Use GParted tool to shrink Windows partition and create extra space at the start of the drive. I needed to create room for an EFI partition (which in the worst case must be minimum of 260MiB). Also needed room for an MSR partition (16 MiB). So I created space for 276 MiB at the start of drive using GParted.
3) Use diskpart from bootable windows 10 USB media to create EFI and MSR partitions. More info about this step, and sizes needed, can be found at https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/configure-uefigpt-based-hard-drive-partitions
-- basically just these commands:
diskpart
select disk 0
(was already using gpt...

eddified

Distinguished
Jul 20, 2013
43
3
18,545
OK here is what I did to get it to work
1) Burn GParted live ISO to usb, and boot from it
2) Use GParted tool to shrink Windows partition and create extra space at the start of the drive. I needed to create room for an EFI partition (which in the worst case must be minimum of 260MiB). Also needed room for an MSR partition (16 MiB). So I created space for 276 MiB at the start of drive using GParted.
3) Use diskpart from bootable windows 10 USB media to create EFI and MSR partitions. More info about this step, and sizes needed, can be found at https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/configure-uefigpt-based-hard-drive-partitions
-- basically just these commands:
diskpart
select disk 0
(was already using gpt so no need to convert)
create partition efi size=260
format quick fs=fat32 label="System"
assign letter="S"
create partition msr size=16
4) restarted computer, went into BIOS and disabled CSM
5) booted again into windows from usb bootable media
6) ran this command:
bootrec /RebuildBcd

Done! Windows boots fine, doesn't use the old HDD bootloader, and doesn't ask me which installation of windows i want to boot each time i turn the computer on. yay!
 
Solution