0. World Community Grid

新型コロナウイルス感染症のワクチン探索を支援するマシン (Raspberry Pi) の構築

グリッド・コンピューティングプロジェクトのひとつ、World Community Gridの「OpenPandemics - COVID-19」に参加してウイルス性タンパク質を解明し有効な化合物の治療薬候補を探す科学者を支援します
参加はこちらから https://join.worldcommunitygrid.org?recruiterId=703087
本稿は以下のアカウントを利用
https://www.worldcommunitygrid.org/verifyMember.do?name=icesword.org&code=da57846a88d204d2ca5b2b6b6dcdcd21
Weak Account Key : 1069089_3663b87e4245e8013ebbe73cee200e7b


1. 検証環境

シングルボードコンピュータ メモリ ストレージ
Raspberry Pi 3 Model B Rev 1.2 1GB microSDHC 32GB CLASS10
Raspberry Pi 3 Model B Plus Rev 1.3 1GB microSDHC 32GB CLASS10
Raspberry Pi 4 Model B Rev 1.4 2GB microSDHC 32GB CLASS10
Raspberry Pi 4 Model B Rev 1.2 4GB microSDHC 32GB CLASS10
Raspberry Pi 4 Model B Rev 1.4 8GB microSDHC 32GB CLASS10

2. OS

raspbian-buster-lite
https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2020-02-14/2020-02-13-raspbian-buster-lite.zip


3. 操作環境

macOS, SSH


4. 書き込み

差し込んだmicroSDHCカードを diskutil list でマウント確認をmacOSのターミナルで行う

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE  NAME                     SIZE       IDENTIFIER
   0:      GUID_partition_scheme                          *121.3 GB   disk0
   1:                        EFI  EFI                      314.6 MB   disk0s1
   2:                 Apple_APFS  Container disk1          121.0 GB   disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE  NAME                     SIZE       IDENTIFIER
   0:      APFS Container Scheme -                        +121.0 GB   disk1
                                  Physical Store disk0s2
   1:                APFS Volume  Macintosh HD - Data      37.7 GB    disk1s1
   2:                APFS Volume  Preboot                  487.3 MB   disk1s2
   3:                APFS Volume  Recovery                 622.9 MB   disk1s3
   4:                APFS Volume  VM                       1.1 GB     disk1s4
   5:                APFS Volume  Macintosh HD             15.3 GB    disk1s5
   6:              APFS Snapshot  com.apple.os.update-...  15.3 GB    disk1s5s1

/dev/disk2 (external, physical):
   #:                       TYPE  NAME                     SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                          *31.9 GB    disk2
   1:                 DOS_FAT_32  BOOT                     268.4 MB   disk2s1
   2:                      Linux                           31.6 GB    disk2s2

結果 disk2 と判明

$ diskutil umountDisk /dev/disk2
Unmount of all volumes on disk2 was successful

書き込むイメージファイルが格納されている階層へ移動

$ cd desktop

書き込み

$ sudo dd bs=1m if=2020-02-13-raspbian-buster-lite.img of=/dev/disk2

書き込んだイメージに空の ssh ファイル配置

bcm2710-rpi-3-b-plus.dtb
bcm2708-rpi-b-plus.dtb
bcm2708-rpi-b.dtb
bcm2708-rpi-cm.dtb
bcm2708-rpi-zero-w.dtb
bcm2708-rpi-zero.dtb
bcm2709-rpi-2-b.dtb
bcm2710-rpi-2-b.dtb
bcm2710-rpi-3-b.dtb
bcm2710-rpi-cm3.dtb
bcm2711-rpi-4-b.dtb
bootcode.bin
cmdline.txt
config.txt
COPYING.linux
fixup_cd.dat
fixup_db.dat
fixup_x.dat
fixup.dat
fixup4.dat
fixup4cd.dat
fixup4db.dat
fixup4x.dat
issue.txt
kernel.img
kernel7.img
kernel7l.img
kernel8.img
LICENCE.broadcom
overlays
ssh
start_cd.elf
start_db.elf
start_x.elf
start.elf
start4.elf
start4cd.elf
start4db.elf
start4x.elf

5. SSH接続

Raspberry Pi へ microSDHCカード を差し込みLANケーブルを接続後、電源投入 Raspberry Pi 本体には電源スイッチが無いため、電源コードを接続する事で起動

Raspberry Pi のSSHリモート操作環境は Termius を利用
https://apps.apple.com/jp/app/termius-ssh-client/id1176074088

ホスト名 raspberrypi.local
ユーザー名 pi
パスワード raspberry

6. OS確認

$ more /proc/device-tree/model | sed "s/$/\n/";getconf LONG_BIT | sed "s/^/os: /" | sed "s/$/bit/";arch | sed "s/^/kernel: /"
$ lsb_release -a

7. 一時ユーザー作成

$ sudo useradd -M tmp
$ sudo gpasswd -a tmp sudo
Adding user tmp to group sudo
$ sudo passwd tmp
Enter new UNIX password:qwerty
Retype new UNIX password:qwerty
passwd: password updated successfully

一時ユーザー tmp のパスワードを qwerty で設定
パスワードは任意の文字列です

$ exit

SSH接続

ホスト名 raspberrypi.local
ユーザー名 tmp
パスワード qwerty

8. ユーザー名変更

$ sudo usermod -l overdroid pi

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for tmp:qwerty

pi ユーザーを overdroid に変更
変更ユーザー名は任意の文字列です

$ sudo usermod -d /home/overdroid -m overdroid
$ sudo groupmod -n overdroid pi
$ exit

SSH接続

ホスト名 raspberrypi.local
ユーザー名 overdroid
パスワード raspberry

9. 一時ユーザー削除

$ sudo userdel tmp

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for overdroid: raspberry

10. パスワード変更、ホスト名変更、名前解決追加

$ passwd
Changing password for overdroid.
(current) UNIX password:raspberry
Enter new UNIX password:qwerty
Retype new UNIX password:qwerty
passwd: password updated successfully

ユーザー overdroid のパスワードを qwerty で設定
パスワードは任意の文字列です

$ sudo passwd root
Enter new UNIX password:qwerty
Retype new UNIX password:qwerty
passwd: password updated successfully

管理者 root のパスワードを qwerty で設定
パスワードは任意の文字列です

$ sudo su -
# hostnamectl set-hostname icesword0x

ホスト名を icesword0x で設定
ホスト名は任意の文字列です

# sh -c 'echo 127.0.1.1 $(hostname) >> /etc/hosts'

11. hostsファイル編集

# vi /etc/hosts

6行目をコメントアウトもしくは dd で行を削除

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

#127.0.1.1               raspberrypi
127.0.1.1 icesword0x

12. ログインメッセージ編集

# vi /etc/motd

既存記述を :%d で全て削除

Change the world a bit.
 _                                    _ 
(_) ___ ___ _____      _____  _ __ __| |
| |/ __/ _ / __\ \ /\ / / _ \| '__/ _` |
| | (_|  __\__ \\ V  V | (_) | | | (_| |
|_|\___\___|___/ \_/\_/ \___/|_|  \__,_|
                                        
Ignition to OVERDROID

13. 温度制御、電源ランプ点滅、Bluetooth無効化、Wi-Fi無効化、再起動

# vi /boot/config.txt

既存記述を :%d で全て削除

dtparam=pwr_led_trigger=heartbeat
temp_limit=75
dtoverlay=disable-bt
dtoverlay=disable-wifi
# reboot

SSH接続

ホスト名 icesword0x.local
ユーザー名 overdroid
パスワード qwerty

14. 各種アップデート、必要パッケージインストール、不要パッケージ削除、再起動

$ sudo su -
# apt-get update && apt-get -y upgrade && apt-get -y install boinc htop unattended-upgrades chkconfig && apt-get autoremove -y man manpages && reboot

18. SSH接続

ホスト名 icesword0x.local
ユーザー名 overdroid
パスワード qwerty

15. zram

$ sudo su -
# vi /usr/bin/zram.sh
#!/bin/bash
cores=$(nproc --all)
modprobe zram num_devices=$cores
swapoff -a
totalmem=`free | grep -e "^Mem:" | awk '{print $2}'`
mem=$(( ($totalmem * 2 / $cores)* 1024 ))
modprobe deflate
modprobe zlib
modprobe lz4hc_compress
core=0
while [ $core -lt $cores ]; do
  echo deflate > /sys/block/zram$core/comp_algorithm ||
   echo zlib > /sys/block/zram$core/comp_algorithm ||
   echo lz4hc > /sys/block/zram$core/comp_algorithm ||
   echo lz4 > /sys/block/zram$core/comp_algorithm
# not sure which one this kernel has
  echo $mem > /sys/block/zram$core/disksize
  mkswap /dev/zram$core
  swapon --discard -p 5 /dev/zram$core # reclaim memory better
  let core=core+1
done
# chmod +x /usr/bin/zram.sh

16. HDMI無効化、USB無効化、zram

# apt install libusb-1.0-0-dev git
Do you want to continue? [Y/n] y
# git clone https://github.com/mvp/uhubctl
# cd uhubctl
# make
# make install
# cd ~
# vi /etc/rc.local

20行目に tvservice --off を追記
21行目に uhubctl -l 1-1 -p 2 -a 0 を追記
22行目に /usr/bin/zram.sh & を追記

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

tvservice --off
uhubctl -l 1-1 -p 2 -a 0
/usr/bin/zram.sh &

exit 0

17. journald

# vi /etc/systemd/journald.conf

15行目に Storage=none を追記

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See journald.conf(5) for details.

[Journal]
Storage=none
#Storage=auto
#Compress=yes
#Seal=yes
#SplitMode=uid
#SyncIntervalSec=5m
#RateLimitIntervalSec=30s
#RateLimitBurst=10000
#SystemMaxUse=
#SystemKeepFree=
#SystemMaxFileSize=
#SystemMaxFiles=100
#RuntimeMaxUse=
#RuntimeKeepFree=
#RuntimeMaxFileSize=
#RuntimeMaxFiles=100
#MaxRetentionSec=
#MaxFileSec=1month
#ForwardToSyslog=yes
#ForwardToKMsg=no
#ForwardToConsole=no
#ForwardToWall=yes
#TTYPath=/dev/console
#MaxLevelStore=debug
#MaxLevelSyslog=debug
#MaxLevelKMsg=notice
#MaxLevelConsole=info
#MaxLevelWall=emerg
#LineMax=48K
#ReadKMsg=yes

18. fstab

# vi /etc/fstab

4行目に tmpfs /tmp tmpfs defaults,noatime,nodiratime,mode=1777 0 0 を追記

proc            /proc           proc    defaults          0       0
PARTUUID=738a4d67-01  /boot           vfat    defaults          0       2
PARTUUID=738a4d67-02  /               ext4    defaults,noatime  0       1
tmpfs    /tmp                              tmpfs    defaults,noatime,nodiratime,mode=1777  0       0
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

19. folder2ram

# wget -O /sbin/folder2ram https://raw.githubusercontent.com/bobafetthotmail/folder2ram/master/debian_package/sbin/folder2ram
# chmod +x /sbin/folder2ram
# folder2ram -configure
# vi /etc/folder2ram/folder2ram.conf

17行目に tmpfs /var/log を追記
18行目に tmpfs /var/tmp を追記
19行目に tmpfs /var/spool を追記
20行目に tmpfs /var/lib/boinc-client/slots を追記

#############################
#folder2ram main config file#
#############################
#
#PROTIP: to make /var/lock or /tmp available as ram filesystems,
#        it is preferable to set the variables RAMTMP, RAMLOCK
#        in /etc/default/tmpfs.
#
#TYPE: options available are "tmpfs" (for a ram folder)
#
#OPTIONS: mount option (will be passed as options to mount), if left blank "defaults" will be used
#
#IMPORTANT: use 2 Tabs to separate "type" from "mount point" from "options", the script needs them to read correctly the configuration.
#
#[type]         [mount point]                   [options]
#tmpfs          /var/log
tmpfs           /var/log
tmpfs           /var/tmp
tmpfs           /var/spool
tmpfs           /var/lib/boinc-client/slots
# folder2ram -mountall
# folder2ram -enablesystemd

20. アップデート自動化(セキュリティのみ)

# dpkg-reconfigure -plow unattended-upgrades
[YES]

YES を選択

# vi /etc/apt/apt.conf.d/50unattended-upgrades

既存記述を :%d で全て削除

// Unattended-Upgrade::Origins-Pattern controls which packages are
// upgraded.
//
// Lines below have the format format is "keyword=value,...".  A
// package will be upgraded only if the values in its metadata match
// all the supplied keywords in a line.  (In other words, omitted
// keywords are wild cards.) The keywords originate from the Release
// file, but several aliases are accepted.  The accepted keywords are:
//   a,archive,suite (eg, "stable")
//   c,component     (eg, "main", "contrib", "non-free")
//   l,label         (eg, "Debian", "Debian-Security")
//   o,origin        (eg, "Debian", "Unofficial Multimedia Packages")
//   n,codename      (eg, "jessie", "jessie-updates")
//     site          (eg, "http.debian.net")
// The available values on the system are printed by the command
// "apt-cache policy", and can be debugged by running
// "unattended-upgrades -d" and looking at the log file.
//
// Within lines unattended-upgrades allows 2 macros whose values are
// derived from /etc/debian_version:
//   ${distro_id}            Installed origin.
//   ${distro_codename}      Installed codename (eg, "jessie")
Unattended-Upgrade::Origins-Pattern {
        // Codename based matching:
        // This will follow the migration of a release through different
        // archives (e.g. from testing to stable and later oldstable).
//      "o=Debian,n=jessie";
//      "o=Debian,n=jessie-updates";
//      "o=Debian,n=jessie-proposed-updates";
//      "o=Debian,n=jessie,l=Debian-Security";
 
        // Archive or Suite based matching:
        // Note that this will silently match a different release after
        // migration to the specified archive (e.g. testing becomes the
        // new stable).
      "o=Debian,a=stable";
//      "o=Debian,a=stable-updates";
//      "o=Debian,a=proposed-updates";
        "origin=Debian,codename=${distro_codename},label=Debian-Security";
};
 
// List of packages to not update (regexp are supported)
Unattended-Upgrade::Package-Blacklist {
//      "vim";
//      "libc6";
//      "libc6-dev";
//      "libc6-i686";
};
 
// This option allows you to control if on a unclean dpkg exit
// unattended-upgrades will automatically run
//   dpkg --force-confold --configure -a
// The default is true, to ensure updates keep getting installed
//Unattended-Upgrade::AutoFixInterruptedDpkg "false";
 
// Split the upgrade into the smallest possible chunks so that
// they can be interrupted with SIGUSR1. This makes the upgrade
// a bit slower but it has the benefit that shutdown while a upgrade
// is running is possible (with a small delay)
//Unattended-Upgrade::MinimalSteps "true";
 
// Install all unattended-upgrades when the machine is shuting down
// instead of doing it in the background while the machine is running
// This will (obviously) make shutdown slower
//Unattended-Upgrade::InstallOnShutdown "true";
 
// Send email to this address for problems or packages upgrades
// If empty or unset then no email is sent, make sure that you
// have a working mail setup on your system. A package that provides
// 'mailx' must be installed. E.g. "user@example.com"
//Unattended-Upgrade::Mail "root";
 
// Set this value to "true" to get emails only on errors. Default
// is to always send a mail if Unattended-Upgrade::Mail is set
//Unattended-Upgrade::MailOnlyOnError "true";
 
// Do automatic removal of new unused dependencies after the upgrade
// (equivalent to apt-get autoremove)
//Unattended-Upgrade::Remove-Unused-Dependencies "false";
 
// Automatically reboot *WITHOUT CONFIRMATION* if
//  the file /var/run/reboot-required is found after the upgrade
Unattended-Upgrade::Automatic-Reboot "true";
 
// Automatically reboot even if there are users currently logged in.
//Unattended-Upgrade::Automatic-Reboot-WithUsers "true";
 
// If automatic reboot is enabled and needed, reboot at the specific
// time instead of immediately
//  Default: "now"
Unattended-Upgrade::Automatic-Reboot-Time "02:00";
 
// Use apt bandwidth limit feature, this example limits the download
// speed to 70kb/sec
//Acquire::http::Dl-Limit "70";
 
// Enable logging to syslog. Default is False
// Unattended-Upgrade::SyslogEnable "false";
 
// Specify syslog facility. Default is daemon
// Unattended-Upgrade::SyslogFacility "daemon";

21. ログ最小限化

# vi /etc/rsyslog.conf

既存記述を :%d で全て削除

#  /etc/rsyslog.conf    Configuration file for rsyslog.
# Some "catch-all" log files.
#                       For more information see
#.=debug;\              /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html
        auth,authpriv.none;\
        news.none;mail.none     -/var/log/debug
#################;*.=warn;\
#### MODULES ####priv.none;\
#################on.none;\
        mail,news.none          -/var/log/messages
module(load="imuxsock") # provides support for local system logging
module(load="imklog")   # provides kernel logging support
#module(load="immark")  # provides --MARK-- message capability

# provides UDP syslog reception
#module(load="imudp")
#input(type="imudp" port="514")

# provides TCP syslog reception
#module(load="imtcp")
#input(type="imtcp" port="514")


###########################
#### GLOBAL DIRECTIVES ####
###########################

#
# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.
#
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

#
# Set the default permissions for all log files.
#
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022

#
# Where to place spool and state files
#
$WorkDirectory /var/spool/rsyslog

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf


###############
#### RULES ####
###############

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
#daemon.*                       -/var/log/daemon.log
#kern.*                         -/var/log/kern.log
#lpr.*                          -/var/log/lpr.log
#mail.*                         -/var/log/mail.log
#user.*                         -/var/log/user.log

#
# Logging for the mail system.  Split it up so that
# it is easy to write scripts to parse these files.
#
#mail.info                      -/var/log/mail.info
#mail.warn                      -/var/log/mail.warn
#mail.err                       /var/log/mail.err

#
# Some "catch-all" log files.
#
#*.=debug;\
#       auth,authpriv.none;\
#       news.none;mail.none     -/var/log/debug
*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
        cron,daemon.none;\
        mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                         :omusrmsg:*

22. 不要サービス停止、再起動

# systemctl stop rsyslog
# systemctl disable rsyslog
# systemctl stop hciuart bluetooth
# systemctl disable hciuart bluetooth
# chkconfig triggerhappy off && chkconfig alsa-utils off && chkconfig off && reboot

SSH接続

ホスト名 icesword0x.local
ユーザー名 overdroid
パスワード qwerty

23. SWAP無効化

$ sudo su -
# swapoff --all
# systemctl stop dphys-swapfile
# systemctl disable dphys-swapfile
# systemctl status dphys-swapfile
# rm /var/swap

24. BOINC起動

# boinccmd --project_attach https://www.worldcommunitygrid.org 1069089_3663b87e4245e8013ebbe73cee200e7b

25. 確認

# free
              total        used        free      shared  buff/cache   available
Mem:         946392      189168      628156         368      129068      705628
Swap:             0           0           0
# chkconfig dphys-swapfile -list
dphys-swapfile            0:off  1:off  2:off  3:off  4:off  5:off  6:off
# zramctl
NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram3 deflate     462.1M   4K   68B    4K       4 
/dev/zram2 deflate     462.1M   4K   68B    4K       4 
/dev/zram1 deflate     462.1M   4K   68B    4K       4 
/dev/zram0 deflate     462.1M   4K   67B    4K       4 
# swapon --show
# htop
htop [CTRL]+[C]で終了

CPU温度確認

$ while true; do vcgencmd measure_temp; sleep 1s; done
[CTRL]+[C]で終了

CPU周波数表示

$ while true; do vcgencmd measure_clock arm; sleep 1s; done
[CTRL]+[C]で終了

CPU電圧表示

$ while true; do vcgencmd measure_volts; sleep 1s; done
[CTRL]+[C]で終了

BOINCホスト情報取得

$ boinccmd --get_host_info

BOINC一時停止

$ boinccmd --quit

シャットダウン

$ sudo shutdown -h now

Raspberry Pi 3 Model B

https://www.boincstats.com/stats/15/host/detail/8364639

$ cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 3 Model B Rev 1.2
$ cat /proc/meminfo | grep MemTotal
MemTotal : 946392 kB

Raspberry Pi 3 Model B Plus

rig1 : https://www.boincstats.com/stats/15/host/detail/8402848

rig2 : https://www.boincstats.com/stats/15/host/detail/8403905

$ cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 3 Model B Plus Rev 1.3
$ cat /proc/meminfo | grep MemTotal
MemTotal : 946392 kB

Raspberry Pi 4 Model B 2GB

https://www.boincstats.com/stats/15/host/detail/8406402

$ cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 4 Model B Rev 1.4
$ cat /proc/meminfo | grep MemTotal
MemTotal : 1911708 kB

Raspberry Pi 4 Model B 4GB

https://www.boincstats.com/stats/15/host/detail/8406152

$ cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 4 Model B Rev 1.2
$ cat /proc/meminfo | grep MemTotal
MemTotal : 3919516 kB

Raspberry Pi 4 Model B 8GB

https://www.boincstats.com/stats/15/host/detail/8401130

$ cat /proc/cpuinfo | grep Model
Model : Raspberry Pi 4 Model B Rev 1.4
$ cat /proc/meminfo | grep MemTotal
MemTotal : 8064668 kB

Mac mini (M1, 2020)

rig1 : https://www.boincstats.com/stats/15/host/detail/8405613

rig2 : https://www.boincstats.com/stats/15/host/detail/8406096

% system_profiler SPHardwareDataType
Hardware:

Hardware Overview:

Model Name: Mac mini
Model Identifier: Macmini9,1
Chip: Apple M1
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 6723.140.2
OS Loader Version: 6723.140.2

AMD Ryzen 7 2700

https://www.boincstats.com/stats/15/host/detail/6778784

C:\> wmic CPU get Name
Name
AMD Ryzen 7 2700 Eight-Core Processor

0. Ethereum Private Blockchain

Raspberry Pi 4でEthereumのプライベートネットワークを構築

分散コンピューティングプロジェクトのひとつ、EthereumをRaspberry Pi 4に構築してプライベート取引を学ぶ
https://github.com/ethereum/go-ethereum


1. 検証環境

シングルボードコンピュータ メモリ ストレージ
Raspberry Pi 4 Model B Rev 1.4 8GB microSDHC 32GB CLASS10

2. OS

raspios-buster-arm64-lite
https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2021-05-28/2021-05-07-raspios-buster-arm64-lite.zip


3. 操作環境

macOS, SSH


4. 書き込み

差し込んだmicroSDHCカードを diskutil list でマウント確認をmacOSのターミナルで行う

$ diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE  NAME                     SIZE       IDENTIFIER
   0:      GUID_partition_scheme                          *121.3 GB   disk0
   1:                        EFI  EFI                      314.6 MB   disk0s1
   2:                 Apple_APFS  Container disk1          121.0 GB   disk0s2
   
/dev/disk1 (synthesized):
   #:                       TYPE  NAME                     SIZE       IDENTIFIER
   0:      APFS Container Scheme -                        +121.0 GB   disk1
                                  Physical Store disk0s2
   1:                APFS Volume  Macintosh HD - Data      37.7 GB    disk1s1
   2:                APFS Volume  Preboot                  487.3 MB   disk1s2
   3:                APFS Volume  Recovery                 622.9 MB   disk1s3
   4:                APFS Volume  VM                       1.1 GB     disk1s4
   5:                APFS Volume  Macintosh HD             15.3 GB    disk1s5
   6:              APFS Snapshot  com.apple.os.update-...  15.3 GB    disk1s5s1
   
/dev/disk2 (external, physical):
   #:                       TYPE  NAME                     SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                          *31.9 GB    disk2
   1:                 DOS_FAT_32  BOOT                     268.4 MB   disk2s1
   2:                      Linux                           31.6 GB    disk2s2

結果 disk2 と判明

$ diskutil umountDisk /dev/disk2
Unmount of all volumes on disk2 was successful

書き込むイメージファイルが格納されている階層へ移動

$ cd desktop

書き込み

$ sudo dd bs=1m if=2021-05-07-raspios-buster-arm64-lite.img of=/dev/disk2

書き込んだイメージに空の ssh ファイル配置

bcm2710-rpi-2-b.dtb
bcm2710-rpi-3-b-plus.dtb
bcm2710-rpi-3-b.dtb
bcm2710-rpi-cm3.dtb
bcm2711-rpi-4-b.dtb
bcm2711-rpi-400.dtb
bcm2711-rpi-cm4.dtb
bootcode.bin
cmdline.txt
config.txt
COPYING.linux
fixup_cd.dat
fixup_db.dat
fixup_x.dat
fixup.dat
fixup4.dat
fixup4cd.dat
fixup4db.dat
fixup4x.dat
issue.txt
kernel8.img
LICENCE.broadcom
overlays
ssh
start_cd.elf
start_db.elf
start_x.elf
start.elf
start4.elf
start4cd.elf
start4db.elf
start4x.elf

5. SSH接続

Raspberry Pi へ microSDHCカード を差し込みLANケーブルを接続後、電源投入 Raspberry Pi 本体には電源スイッチが無いため、電源コードを接続する事で起動

Raspberry Pi のSSHリモート操作環境は Termius を利用
https://apps.apple.com/jp/app/termius-ssh-client/id1176074088

ホスト名 raspberrypi.local
ユーザー名 pi
パスワード raspberry

6. 古いパッケージ削除

$ sudo su -
# apt-get remove golang autoremove

7. 各種アップデート、必要パッケージインストール、再起動

# apt-get update && apt-get -y upgrade && apt-get -y install git golang libgmp3-dev htop && reboot

SSH接続

ホスト名 raspberrypi.local
ユーザー名 pi
パスワード raspberry

8. golangインストール

$ sudo su -
# wget https://dl.google.com/go/go1.9.2.linux-armv6l.tar.gz
# tar -C /usr/local -xzf go1.9.2.linux-armv6l.tar.gz

9. 環境パス編集

# vi ~/.profile

10行目に export PATH=$PATH:/usr/local/go/bin を追記

# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi

mesg n || true
export PATH=$PATH:/usr/local/go/bin

10. myGenesis.json作成

# mkdir private
# cd private
# vi myGenesis.json
{
  "config": {
  "chainId" : 15,
  "homesteadBlock" : 0,
  "eip155Block" : 0,
  "eip158Block" : 0
  },
  "nonce": "0x0000000000000042",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "extraData": "0x00",
  "gasLimit": "0x8000000",
  "difficulty": "0x4000",
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x3333333333333333333333333333333333333333",
  "alloc": {}
}

11. gethのビルドとインストール

# git clone -b release/1.8 https://github.com/ethereum/go-ethereum.git
# cd go-ethereum
# make
# cp build/bin/geth /usr/local/bin/
ブロックチェーン初期化
# geth --datadir /root/private init /root/private/myGenesis.json

12. gethの起動

# geth --networkid "10" --nodiscover --datadir "/root/private" console 2>> /root/private/geth.log
Welcome to the Geth JavaScript console!

instance: Geth/v1.8.27-stable-4bcc0a37/linux-arm64/go1.11.6
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> 

13. アカウント作成

> personal.newAccount("qwerty")
"0xc278d7070cd0cfb62c9199dcc988335997e8617e"
> 
> personal.newAccount("ji32k7au4a83")
"0x19e3635b94c457fee194b178d49f246d3c5c417f"

1つ目のアカウントパスワードは qwerty で設定
2つ目のアカウントパスワードは ji32k7au4a83 で設定


14. アカウントアドレス確認

> eth.accounts
["0xc278d7070cd0cfb62c9199dcc988335997e8617e", "0x19e3635b94c457fee194b178d49f246d3c5c417f"]
> 
> eth.accounts[0]
"0xc278d7070cd0cfb62c9199dcc988335997e8617e"
> eth.accounts[1]
"0x19e3635b94c457fee194b178d49f246d3c5c417f"

15. マイニング成功時に報酬を受け取るアカウント確認

> eth.coinbase
"0xc278d7070cd0cfb62c9199dcc988335997e8617e"
補足 報酬を受け取るアカウントを変更するコマンド
> miner.setEtherbase(eth.accounts[1])
true

16. Etherマイニング実行

> miner.start()
null
> eth.mining
true

17. ブロック、ハッシュレート確認

> eth.blockNumber
0
> eth.blockNumber
433
> eth.hashrate
75205
htop htop

18. 残高確認

> eth.getBalance(eth.accounts[0])
2.3e+21
> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
2300
> eth.getBalance(eth.accounts[1])
0

19. 送金、トランザクション、残高確認

送金元 eth.accounts[0] のアカウントロック解除
> personal.unlockAccount(eth.accounts[0], "qwerty")
eth.accounts[1] へ 100ETH 送金
> eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(100, "ether")})
"0x19e327ab08a759f26094fcc3bc8f6571d8e34336f32dc2655a065ff13e8c2b10"
トランザクション情報確認
> eth.getTransaction("0x19e327ab08a759f26094fcc3bc8f6571d8e34336f32dc2655a065ff13e8c2b10")
{
  blockHash: "0x9956edf75adfa3d4c555be5205d4be0f07ff81a242548ee2764785aafd7cef02",
  blockNumber: 461,
  from: "0xc278d7070cd0cfb62c9199dcc988335997e8617e",
  gas: 90000,
  gasPrice: 1000000000,
  hash: "0x19e327ab08a759f26094fcc3bc8f6571d8e34336f32dc2655a065ff13e8c2b10",
  input: "0x",
  nonce: 0,
  r: "0x474f41a72be303f211ee9196ccb2e444e96165e73f3c1f08273ef4b5dcaa142a",
  s: "0x26307f21924439845e04d05affd51ad0eb88de3f3e2efad5de68163e991b7bf2",
  to: "0x19e3635b94c457fee194b178d49f246d3c5c417f",
  transactionIndex: 0,
  v: "0x42",
  value: 100000000000000000000
}
残高確認
> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
2200
> web3.fromWei(eth.getBalance(eth.accounts[1]), "ether")
100
マイニング停止
> miner.stop()
null

Overdroid KAWAII Sticker 1

https://store.line.me/stickershop/product/5691192/ja

Overdroid KAWAII Sticker 1

商標公開2018-065195

商標 OVER DROID 称呼 オーバードロイド

電子応用機械器具及びその部品

https://www.j-platpat.inpit.go.jp/c1800/TR/JP-2018-065195/256C5605EA9885A78DEB9DD22547AA78794ADDEBA094FDF9F9328E5EFEE25537/40/ja

2018-065195

商標公開2021-005244

預金の受入れ(債券の発行により代える場合を含む。)及び定期積金の受入れ,資金の貸付け及び手形の割引,内国為替取引,債務の保証及び手形の引受け,有価証券の貸付け,金銭債権の取得及び譲渡,有価証券・貴金属その他の物品の保護預かり,両替,金融先物取引の受託,金銭・有価証券・金銭債権・動産・土地若しくはその定著物又は地上権若しくは土地の賃借権の信託の引受け,債券の募集の受託,外国為替取引,信用状に関する業務,信用購入あっせん,前払式支払手段の発行,他人のために行う暗号資産の管理,暗号資産の利用者に代わってする支払代金の清算及び決済,暗号資産の売買又は他の暗号資産との交換,暗号資産の売買又は他の暗号資産との交換の媒介・取次ぎ・代理,暗号資産の送金事務の取扱い,暗号資産の売買又は他の暗号資産との交換に関して行う利用者の金銭の管理,前払式電子仮想通貨の発行及び管理

https://www.j-platpat.inpit.go.jp/c1800/TR/JP-2021-005244/ECC2A259CAF5B8548AFD07271018208CB58A2797A3674C7FD05AD6826C16CDD2/40/ja

2021-005244

商標公開2021-005245

電子応用機械器具及びその部品,電子計算機用プログラム,暗号資産を受信し及び使用するためのダウンロード可能な暗号鍵

https://www.j-platpat.inpit.go.jp/c1800/TR/JP-2021-005245/2E43069D657D6E4B8291FC8D6D5F84AB0AB21FCD9CF02FEB6FAC28B57920A56F/40/ja

2021-005245

特開2020-091557

分散コンピューティング仲介システム、方法及びプログラム

https://www.j-platpat.inpit.go.jp/c1800/PU/JP-2020-091557/2FF836DEBAD7689871D27CD6E278C3470424CBFFE18ACCBFEBA56072B193FFE4/11/ja

2020-091557

myna.me

Creation Date: 2008-07-10T03:30:40Z


ena.network

Creation Date: 2021-06-04T02:37:56Z


bitcoin.ne.jp

[登録年月日] 2013/07/08


株式会社アイスソード

本社 神奈川県横浜市磯子区杉田3丁目7−26
代表取締役 森本 拓矢
設立 2017年5月9日
事業内容 コンピュータエンタテインメント