linux pcie show available slots

Today I had a request from our user for add a PCIe SSD card to a server. One option is you walk to this server and open it. This not the best option to check if it a PCIe slot available.
Another option is use your Linux commandline.

You need your server mainboard manual to see which slot is labeled.

You have only to check under current usage is in use or available.

Current Usage: Available

dmidecode -t 9
# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 3.2.1 present.
# SMBIOS implementations newer than version 3.2.0 are not
# fully supported by this version of dmidecode.
 
Handle 0x000B, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU1 SLOT2 PCI-E 3.0 X16
        Type: x16 PCI Express 3 x16
        Current Usage: In Use
        Length: Long
        ID: 2
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:18:00.0
 
Handle 0x000C, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU1 SLOT4 PCI-E 3.0 X16
        Type: x16 PCI Express 3 x16
        Current Usage: In Use
        Length: Short
        ID: 4
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:3b:00.0
 
Handle 0x000D, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU2 SLOT6 PCI-E 3.0 X16
        Type: x16 PCI Express 3 x16
        Current Usage: In Use
        Length: Short
        ID: 6
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:86:00.0
 
Handle 0x000E, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU2 SLOT8 PCI-E 3.0 X16
        Type: x16 PCI Express 3 x16
        Current Usage: In Use
        Length: Short
        ID: 8
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:af:00.0
 
Handle 0x000F, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU1 SLOT9 PCI-E 3.0 X16
        Type: x16 PCI Express 3 x16
        Current Usage: Available
        Length: Short
        ID: 9
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:ff:00.0
 
Handle 0x0010, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU2 SLOT10 PCI-E 3.0 X16
        Type: x16 PCI Express 3 x16
        Current Usage: Available
        Length: Short
        ID: 10
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:ff:00.0
 
Handle 0x0011, DMI type 9, 17 bytes
System Slot Information
        Designation: CPU2 SLOT11 PCI-E 3.0 X4(IN X8)
        Type: x4 PCI Express 3 x8
        Current Usage: Available
        Length: Short
        ID: 11
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:ff:00.0
 
Handle 0x0012, DMI type 9, 17 bytes
System Slot Information
        Designation: M.2 CONNECTOR
        Type: x4 M.2 Socket 2
        Current Usage: In Use
        Length: Short
        Characteristics:
                3.3 V is provided
                Opening is shared
                PME signal is supported
        Bus Address: 0000:02:00.0