Raspbian のシェル上から Raspberry Pi 2 と Raspberry Pi 3 を見分ける方法。
テンポラリな実験のつもりで Raspberry Pi 2 と 3 が混在した環境を DHCP ベースで作ってしまった後で、「いまログインしてるのって 2 だっけ? 3 だっけ?」となった時用。
試した Raspbian の環境は以下の通り。
pi@raspberrypi:~ $ uname -a Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux
$ cat /proc/device-tree/model を使う
Raspberry Pi 2 上で実行した場合。
pi@raspberrypi:~ $ cat /proc/device-tree/model
Raspberry Pi 2 Model B Rev 1.1pi@raspberrypi:~ $
Raspberry Pi 3 上で実行した場合。
pi@raspberrypi:~ $ cat /proc/device-tree/model
Raspberry Pi 3 Model B Rev 1.2pi@raspberrypi:~ $
$ iwconfig を使う
Raspberry Pi 3 が WiFi 搭載していのを使った手。
Raspberry Pi 3 で WiFi を無効にしていたり、USB WiFi NIC を着けていたりした場合は
使えないかもしれない。
Raspberry Pi 2 上で実行した場合。wlan がない。
pi@raspberrypi:~ $ iwconfig lo no wireless extensions. eth0 no wireless extensions.
Raspberry Pi 3 上で実行した場合。wlan0 がある。
pi@raspberrypi:~ $ iwconfig wlan0 IEEE 802.11bgn ESSID:off/any Mode:Managed Access Point: Not-Associated Tx-Power=31 dBm Retry short limit:7 RTS thr:off Fragment thr:off Power Management:on lo no wireless extensions. eth0 no wireless extensions.
参考:pi 2 - Is there a Bash command to check if the Raspberry Pi is 2 or 3? - Raspberry Pi Stack Exchange