Why am I seeing a difference in WSL diskdrive list vs registry

I'm trying to understand how WSL2 is interacting with the host Win11 operating system.

WSL diskdrive list brief reports my USB thumbdrive as \\.\PHYSICALDRIVE2 and my internal SSD as \\.\PHYSICALDRIVE0

But in regedit HKLM\HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\ Scsi Bus 0\Target ID 0\Logical Unit Id 0\DeviceName says my SSD is PhysicalDrive2

Any idea why the discrepancy ?


I'm not sure why the registry is reporting a DeviceName for your drive (or what may have generated that propery). In general, it appears the HARDWARE section of the registry is fairly undocumented. And, as you can see, that's not the actual name you need to use for mounting anyway.

For reference, I have three SSD's in my system, and none have a DeviceName in the SCSI section. For example:

> Get-ChildItem 'HKLM:\HARDWARE\DEVICEMAP\Scsi\Scsi Port 5\Scsi Bus 0\Target Id 0\'


    Hive: HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\Scsi\Scsi Port 5\Scsi Bus 0\Target Id 0

Name                           Property
----                           --------
Logical Unit Id 0              InquiryData          : {0, 0, 6, 18...}
                               SerialNumber         : xxxx-xxxxx-xxx
                               Identifier           : NVMe    Samsung SSD 950 BXX7
                               DeviceType           : DiskPeripheral
                               DeviceIdentifierPage : {0, 131, 0, 24...}

It may be that a previous Windows release, or some other software, set this at some point on your system. Even if that name in the registry is valid, it likely applies to that particular SCSI bus/port, and not the system as a whole.

But regardless, the SCSI Bus registry isn't the source of the names you need to use for WSL mounting. That's returned by WMI (via CIM). As you can see in this article:

from where this data is obtained?. Well the answer is, this data is obtained from many sources like the WinApi, the Windows Registry, the SMBIOS or custom functions embedded inside of the MOF definition.

So we can't necessarily expect that you will be able to get the drive information directly from the Registry alone. Also from that article, there is apparently a way to determine how WMI is retrieving those values, but I haven't dived into that Delphi code to see how it might be mapped to PowerShell. The equivalent PowerShell article seems to have been taken offline by Microsoft, probably since WMI has been superseded by CMI in PowerShell.

As the Microsoft Docs say, continue to use ...

GET-CimInstance -query "SELECT * from Win32_DiskDrive"

... to get the proper name to use with wsl --mount. Also note that these do seem to map to the same "Disk numbers" you would see in Computer Management -> Storage -> Disk Management.