Operating System - Linux
1752577 Members
4586 Online
108788 Solutions
New Discussion

Re: How to get Serial number in Linux w/o using dmidecode

 
Sreer
Valued Contributor

How to get Serial number in Linux w/o using dmidecode

Hello Gurus,

 

My dmidecode is not helpfull to get the Serial number of my server.

 

Server details:

[root@server1 ~]# uname -a
Linux server1 2.6.18-348.1.1.el5 #1 SMP Fri Dec 14 05:26:02 EST 2012 i686 i686 i386 GNU/Linux
[root@server1 ~]#
[root@server1 ~]# cat /etc/redhat-rel*
Red Hat Enterprise Linux Server release 5.9 (Tikanga)
[root@server1 ~]#
[root@server1 ~]# rpm -qa | grep -i release
redhat-release-notes-5Server-46
redhat-release-5Server-5.9.0.2
[root@server1 ~]#

 

If I use dmidecode I gets the below o/p.

 


[root@server1 ~]# dmidecode -s system-serial-number
%..#&.....{a.y
[root@server1 ~]#

 

is there any other ways to get the serila number info?

 

Regards,

Sree

7 REPLIES 7
Jimmy Vance
HPE Pro

Re: How to get Serial number in Linux w/o using dmidecode

If you run dmidecode without any options can you see the serial number and other text output OK?

 

I just ran

 

dmidecode -s system-serial-number 

and

dmidecode | grep "Serial Number:"

 

They both show the serial number of the system

 

 

No support by private messages. Please ask the forum! 
panchalchetan
Occasional Visitor

Re: How to get Serial number in Linux w/o using dmidecode

Dear..

 

Install "lshw OR hardinfo" pkgs in your system.

 

This  two utilies find serial number.

VK2COT
Honored Contributor

Re: How to get Serial number in Linux w/o using dmidecode

Hello,

 

Let me add another, not well-known tool - facter.

 

Here is an example from my own CentOS 6.5 server.

dmidecode you already said you do not want to use...

 

# dmidecode -s system-serial-number
Confidential Info Erased

 

# lshw |grep -m1 'serial:'
    serial: Confidential Info Erased

 

# facter | grep serialnumber
serialnumber => Confidential Info Erased

Cheers,

 

VK2COT - Dusan Baljevic
mdella256
New Member

Re: How to get Serial number in Linux w/o using dmidecode

Something that just came up yesterday... If you are using a newer version of the HP BIOS (in this case a DL360p with BIOS P71) you might get the following problem:

 

[root@USE406RK54 ~]# dmidecode -s system-serial-number
# SMBIOS implementations newer than version 2.7 are not
# fully supported by this version of dmidecode.
USE406RK54      
[root@USE406RK54 ~]#

 

The interesting part of this is that you DO get the serial number, however you also get a bunch of text that basically screws up any string scripts that you might be using.   Another way to get this information as the serial number only is the following:

 

/usr/sbin/dmidecode -t 1 | egrep 'Serial' | awk '{print $3}'

 

[root@USE406RK54 init.d]# /usr/sbin/dmidecode -t 1 | egrep 'Serial' | awk '{print $3}'
USE406RK54
[root@USE406RK54 init.d]#

 

This bad behaviour only started with BIOS P71 (just released recently, supporting the new SMBIOS 2.8.0 standard).  The full output of the dmidecode -t 1 is:

 

[root@USE406RK54 init.d]# /usr/sbin/dmidecode -t 1
# dmidecode 2.11
SMBIOS 2.8 present.
# SMBIOS implementations newer than version 2.7 are not
# fully supported by this version of dmidecode.

Handle 0x0100, DMI type 1, 27 bytes
System Information
        Manufacturer: HP
        Product Name: ProLiant DL360p Gen8
        Version: Not Specified
        Serial Number: **Confidential info erased**      
        UUID: 35363636-3233-5355-4534-3036524B3534
        Wake-up Type: Power Switch
        SKU Number: 666532-B21      
        Family: ProLiant

[root@USE406RK54 init.d]#

 

--

 

Side notes:

 

dmidecode released with CentOS (or RHEL) 6.4 and earlier is version 2.11 which does not support the 2.8 version of SMBIOS.  So you'll not *quite* get the answer you want when using the "dmidecode -s system-serial-number" version of this string. You need dmidecode version 2.12 or later to get the latest ROM BIOS reads from HP Gen8 Gear.

 

Personally I'm trying to see if there is a newer version of dmidecode out there for either centos 6.4 or 6.5 or on the updates that handles the newer SMBIOS 2.8.0 standard (its been published since April 2013, but only recently implemented by HP).

GreyGnome
Occasional Visitor

Re: How to get Serial number in Linux w/o using dmidecode

If dmidecode is replying with junk, then your system serial number is junk. I believe you need to go into the BIOS/UEFI and change it. Look on the case of your machine and get its true serial number, then reboot, go into your BIOS, and modify it.

 

We had a number of serial numbers change mysteriously at a job I worked at. We never figured out how that happened.

 

In the meantime, you can also find the system serial number at /sys/devices/virtual/dmi/id/product_serial. ...Requires root to read, but many of the files in /sys/devices/virtual/dmi/id/ are readable by any user.

 

simplylinuxfaq
Frequent Advisor

Re: How to get Serial number in Linux w/o using dmidecode

As "GreyGnome" noted if the "dmidecode" command not providing correct information then it would be that the serial number is not properly set in the BIOS of the system.

 

I had written a script to view hardware information on a linux system.... If anyone interested can look into this:

 

 How To Find Hardware Details In Linux  [Admin: The link is no longer valid> Broken Link removed]

 

Thanks,

Mssm

Thanks,
SimplyLinuxFAQ
Linux_Dude
Occasional Visitor

Re: How to get Serial number in Linux w/o using dmidecode

#!/bin/bash

echo "System Serial Number:"

dmidecode -s system-serial-number

echo "Serial Numbers:"

dmidecode | grep "Serial Number"

# Save this in /usr/local/bin and either chmod u+x or chmod 777. Name it something like sndmidecode. Enjoy