Packetwatch.net

Get system serial number in OpenBSD



Last modified: Dec. 1, 2009

Contents
1 - Summary
2 - Dependencies
3 - Dmidecode installation
4 - Commands


1 - Summary

This guide shows how to get the system serial number and BIOS information
in OpenBSD. It will show how to install the dmidecode package. This has been
tested in OpenBSD 4.3, 4.4 and 4.6.


2 - Dependencies

I've created a shell script that can search the list of available packages.

#!/bin/sh
# This script will look for packages with the search term.

echo=/bin/echo
lynx=/usr/bin/lynx
pkg_path=ftp://ftp.openbsd.org/pub/OpenBSD/$rel/packages/$arch/index.txt
tr=/usr/bin/tr
cut=/usr/bin/cut
grep=/usr/bin/grep

if [ $# -ne 1 ]
    then
        exit 0
    else
        # check if a valid parameter
        if [ "$1" == "-help" ]
            then
                $echo Usage: pkg_find [string]
            else
                $lynx -dump $pkg_path | $tr -s " " | $cut -d " " -f 10 | $grep -i $1
        fi
fi
exit 0

# cd ~
# vi pkg_find
# sudo chown root:bin pkg_find
Password:
# sudo chmod 555 pkg_find
Password:
# sudo mv pkg_find /usr/sbin/
Password:

Here is an example of what it can do.
# pkg_find -help
Usage: pkg_find [string]
# pkg_find dmidecode
dmidecode-*.tgz


3 - Dmidecode installation

Install the dmidecode package.
# pkg_find dmidecode
dmidecode-*.tgz
# sudo pkg_add dmidecode-*.tgz
Password:

Find where the dmidecode binary was installed to.
# pkg_info -L dmidecode-* | grep bin
/usr/local/sbin/biosdecode
/usr/local/sbin/dmidecode
/usr/local/sbin/ownership
/usr/local/sbin/vpddecode

Run ldd to display the shared objects (.so) needed to run the dmidecode binary.
If there are any shared objects in /usr/local you will need to run ldconfig.
# ldd /usr/local/sbin/dmidecode
/usr/local/sbin/dmidecode:
        Start    End      Type Open Ref GrpRef Name
        1c000000 3c00a000 exe  1    0   0      /usr/local/sbin/dmidecode
        0be51000 2be8a000 rlib 0    1   0      /usr/lib/libc.so.51.0
        0b2b3000 0b2b3000 rtld 0    1   0      /usr/libexec/ld.so


4 - Commands

You can display the system information including serial number by typing the
following.
# sudo dmidecode -t 1 | grep -e 'Manufacturer' -e 'Product Name' -e 'Serial Number' | cut -f 2
Password:
Manufacturer: Dell Computer Corporation
Product Name: OptiPlex 170L
Serial Number: XXXXXXX

You can display the BIOS information by typing the following.
# sudo dmidecode -t 0 | grep -e 'Vendor' -e 'Version' -e 'Release Date' | cut -f 2
Password:
Vendor: Dell Computer Corporation
Version: XXX
Release Date: XX/XX/XXXX


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.