makansij
makansij

Reputation: 9875

How do I acquire Linux serial number without lhal, and without dmidecode commands?

There is no interface to the piece of hardware that I'm trying to access the Serial number of, which makes it rather difficult to install new libararies. Also, memory is limited.

Any help is appreciated on how to extract serial number, thanks.

Upvotes: 1

Views: 3764

Answers (2)

user145440
user145440

Reputation: 146

ok, it is late, but this information my help someone:

1 - if the board supports DMI: so you might check the /sys/class/dmi directory: Example on Kernel 3.16 (output values are modified)

~$ sudo cat /sys/class/dmi/id/board_serial
PCDIVZ33X1C320
~$ sudo cat /sys/class/dmi/id/chassis_serial
4CZ145A2S5
~$ sudo cat /sys/class/dmi/id/product_serial
4CZ145A2S5

this allows you to bypass the dmidecode programm and to write language independent programs (no en/de/fr/... output parsing).

2 - if the board documentation serve the information how to read the serial number directly: You may be able to read e.g. the content of an onboard eeprom which holds the serial number. this may be possible throught the /sys filesystem , too. to see, whats possible - an Example from a HP Laptop:

cat  /sys/bus/i2c/devices/*/name
Radeon i2c bit bus 0x90
card0-DP-3
Radeon i2c bit bus 0x91
Radeon i2c bit bus 0x92
Radeon i2c bit bus 0x93
Radeon i2c bit bus 0x94
Radeon i2c bit bus 0x95
Radeon i2c bit bus 0x96
Radeon i2c bit bus 0x97
card0-DP-1
card0-DP-2

sorry for this device not having an eeprom on i2c...

Upvotes: 2

askb
askb

Reputation: 6786

This looks like what you are querying is from the BIOS. The BIOS would contain a table of information about your hardware, serial numbers, etc.. this can be queried according to the SMBIOS standard. dmidecode reads this information from the table using this standard.

So alternatively, you may want to look into the standard and write code for reading the required information or serial numbers etc. or ask your hardware/firmware vendor if they have any libraries or hooks available for this purpose.

Upvotes: 1

Related Questions