Linux get used and unused RAM slots details with dmidecode

$ dmidecode -t 17 | grep "Size:"

Output:

Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 2048 MB
Size: 2048 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed
Size: 2048 MB
Size: 2048 MB

Above output shows that there are 4 used slots and 12 unused slots.

To get number of available RAM slots:

$ dmidecode -t 17 | grep -c "Size:"

or

$ dmidecode -t 17 | grep "Size:" | wc -l

Output:

16

-Sany

Source: viewsby.wordpress.com/2012/11/15/linux-get-used-and-unused-ram-slots-details-with-dmidecode/