Map PCIe slot number (or BDF) to device number or vice versa

busdrivelspcinvmepci-express

Is there any way to know the drive number from BDF or slot number of a PCIe or vice versa?

Suppose I have four PCIe drives attached to my system. And I know their BDF's, I want to know each of the drives corresponding drive number in OS.

Example:

  • /dev/nvme0 for BDF 68:00.0 in Linux, or;
  • /physicalDrive2 for BDF 68:0.0 in Windows.

Best Answer

There is a way in Linux. Try

readlink -f /sys/class/nvme/nvme*

This should show you the BDF number with associated nvme device name.