LoginSignup
3
6

More than 5 years have passed since last update.

Raspberry Piの固有ID

Posted at

Raspberry Piの固有IDについて、調べた。

/proc/cpuinfoにあるので、catで表示する。

# cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : BCM2835
Revision        : a02082
Serial          : 00000000de876543

最後のSerialがシリアル番号になる。
スクリプトなどで使用する場合は、

# grep Serial /proc/cpuinfo|awk '{print $3}'

00000000de876543

で番号のみを取り出せばよい。

また、eth0のMACアドレスは、OSでベンダー番号(b8:27:eb)+シリアルで振っているようなので

# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.3  netmask 255.255.255.0  broadcast 192.168.1.255
        ether b8:27:eb:87:65:43  txqueuelen 1000  (イーサネット)
        RX packets 2194421  bytes 283335546 (270.2 MiB)
        RX errors 0  dropped 1632266  overruns 0  frame 0
        TX packets 116143  bytes 26260222 (25.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

のether部分も固有IDとなるかと思う。

これも

# ifconfig eth0|grep ether|awk '{print $2}'|sed "s/://g"
b827eb876543 

でhexのみを取り出す。

参考:
https://raspberrypi.akaneiro.jp/archives/413
http://boysenberrypi.hatenadiary.jp/entry/2014/03/29/222028

3
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6