I wrote a dirty PowerShell script that does everything for you. Save it as nvme.ps1 - usage below:
To enable the NVMe driver.
nvme.ps1 -EnableNvmeDriver
Run this once, reboot, and then run it again. It's not possible to obtain the GUIDs for safeboot until you have rebooted to utilise the native NVMe driver
To disable the NVMe driver, run:
nvme.ps1 -DisableNvmeDriver
Reboot to complete
Code:
param([switch]$EnableNvmeDriver,
[switch]$DisableNvmeDriver)
if ($EnableNvmeDriver) {
# add reg keys
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 1853569164 /t REG_DWORD /d 1 /f
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 156965516 /t REG_DWORD /d 1 /f
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 735209102 /t REG_DWORD /d 1 /f
# get GUIDs of NVMe devices
$guids = (Get-WmiObject -Query "SELECT * FROM Win32_PnPEntity WHERE PNPClass = 'NvmeDisk'").classguid
$guids = $guids | select -Unique
if ($null -eq $guids) {Write-Output "Restart your machine and run this script again to add the GUIDs and fix safeboot"}
if ($guids) {
# loop through each GUID and add the safeboot keys
foreach ($guid in $guids) {
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\$guid /f
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\$guid /f
}
}
}
if ($DisableNvmeDriver) {
reg delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 1853569164 /f
reg delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 156965516 /f
reg delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 735209102 /f
}
Edit: Safeboot works just fine if you use the script.
Edit 2: Interestingly, the GUID selected from WMI for the "NvmeDisk" class is the same for both devices (75416e63-5912-4dfa-ae8f-3efaccaffb14). This seems to be that the device enumeration refers to the driver GUID as the class GUID, not to the device itself. This is confirmed under HKLM\SYSTEM\CurrentControlSet\Enum\NVME - the GUID is the driver key, but the driver is suffixed with a 4 digit integer to reference the NVMe drive (0000 or 0001, for example).
Bearing that in mind, I have modified the script to only add unique values retrieved during the WMI query. I don't know why any other GUID would be referenced, but this may vary machine to machine before I hardcode it in. Can anyone confirm that the class GUID of their NVMe drives is listed as 75416e63-5912-4dfa-ae8f-3efaccaffb14? Run
(Get-WmiObject -Query "SELECT * FROM Win32_PnPEntity WHERE PNPClass = 'NvmeDisk'").classguid and post the output here, if you would be so kind. If the driver GUID is hardcoded and not unique to each machine, I can hardcode it in the script and that removes the need to reboot.