Closed4

RPi 5で色々する

ピン留めされたアイテム
shuntakashuntaka

ざっくり作業ログをこちらにまとめます。後日ちゃんとブログ化します。


モチベ
昨年くらいから趣味で安価に常駐プロセスをデプロイできるホスティング環境悩んでいました。サーバレス周りはゼロコールドスタートなV8 Isolateを使ったCloudflare WorkersやDeno Deployが無料枠が大きくいい感じです。
一方常駐プロセスはHerokuの無料プランがなくなりました。AWS AppRunnerは起動時間を人間が稼働している時間のみに絞っても10$はかかります。fly.ioは、Legacy hobby planでCPU-1x 256mb VM 3つと3 GB 永続ボリュームストレージは無料で扱えます。fly.ioはCLIもよくできていて、こんなに無料に使わせてくれて最高なSaaSです。
https://zenn.dev/shuntaka/scraps/89303ae818a59f

しかし人間は欲の塊で、永続化領域とメモリがもっと欲しくなったので、自前でコンテナオーケストレーション基盤を作ることにしました。

理由はいろいろ書きましたが、(以下略)。ぶっちゃけn番煎じです。

shuntakashuntaka
  1. Raspberry Pi ImagerでSDカードに書き込み
    注意点: オプションでsshの有効化しないとだめ、ユーザー名とパスワードの設定のみでは不十分
OS
Raspberry Pi OS(64-bit)
  1. Macに有線LANを接続して、「設定」->「ネットワーク」からホストIPを確認
# Xはネットワークに記載している値
$ nmap -sP 192.168.X.1/24
(中略)
Nmap scan report for raspberrypi.lan (192.168.X.56)
Host is up (0.0045s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 21.49 seconds

# もしくは
$ nmap -p22 192.168.X.1/24
(中略)
Nmap scan report for pi-1.lan (192.168.X.56)
Host is up (0.0065s latency).
(中略)
Nmap done: 256 IP addresses (4 hosts up) scanned in 17.29 seconds
  1. Raspberry Pi ImagerでM.2. へのイメージ書き込み
OS
Ubuntu Server 23.10(64-bit)

windowsのデバイスとドライブから、system-bootを開きconfig.txtの一番下に追記します。

config.txt
[all]
kernel=vmlinuz
cmdline=cmdline.txt
initramfs initrd.img followkernel

[pi4]
max_framebuffers=2
arm_boost=1

[all]
# Enable the audio output, I2C and SPI interfaces on the GPIO header. As these
# parameters related to the base device-tree they must appear *before* any
# other dtoverlay= specification
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on

# Comment out the following line if the edges of the desktop appear outside
# the edges of your display
disable_overscan=1

# If you have issues with audio, you may try uncommenting the following line
# which forces the HDMI output into HDMI mode instead of DVI (which doesn't
# support audio output)
#hdmi_drive=2

# Enable the serial pins
enable_uart=1

# Autoload overlays for any recognized cameras or displays that are attached
# to the CSI/DSI ports. Please note this is for libcamera support, *not* for
# the legacy camera stack
camera_auto_detect=1
display_auto_detect=1

# Config settings specific to arm64
arm_64bit=1
dtoverlay=dwc2

[cm4]
# Enable the USB2 outputs on the IO board (assuming your CM4 is plugged into
# such a board)
dtoverlay=dwc2,dr_mode=host

[all]
+ dtparam=nvme
  1. SSH

SDカードへssh

ssh shuntaka@192.168.86.X

ブートローダーの更新

$ sudo rpi-eeprom-update
BOOTLOADER: up to date
   CURRENT: Fri Feb 16 15:28:41 UTC 2024 (1708097321)
    LATEST: Fri Feb 16 15:28:41 UTC 2024 (1708097321)
   RELEASE: default (/lib/firmware/raspberrypi/bootloader-2712/default)
            Use raspi-config to change the release.

最新なのでアップデートは空振りの模様。アップデートした場合、別途sudo rebootが必要

$ sudo rpi-eeprom-update -d -a
BOOTLOADER: up to date
   CURRENT: Fri Feb 16 15:28:41 UTC 2024 (1708097321)
    LATEST: Fri Feb 16 15:28:41 UTC 2024 (1708097321)
   RELEASE: default (/lib/firmware/raspberrypi/bootloader-2712/default)
            Use raspi-config to change the release.
$ env EDITOR=vi sudo -E rpi-eeprom-config --edit
変更前
[all]
BOOT_UART=1
POWER_OFF_ON_HALT=0
BOOT_ORDER=0xf461
変更後
[all]
BOOT_UART=1
POWER_OFF_ON_HALT=0
-BOOT_ORDER=0xf461
+BOOT_ORDER=0xf416
+PCIE_PROBE=1
$ ssh shuntaka@192.168.X.60
shuntaka@192.168.X.60's password:
Welcome to Ubuntu 23.10 (GNU/Linux 6.5.0-1005-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Apr 14 12:06:47 UTC 2024

  System load:            0.25
  Usage of /:             0.4% of 457.97GB
  Memory usage:           3%
  Swap usage:             0%
  Temperature:            40.8 C
  Processes:              139
  Users logged in:        0
  IPv4 address for wlan0: 192.168.X.60
  IPv6 address for wlan0: <IPv6>


115 updates can be applied immediately.
63 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
$ sudo df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           795M  2.9M  792M   1% /run
/dev/nvme0n1p2  458G  2.0G  438G   1% /
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/nvme0n1p1  505M   63M  442M  13% /boot/firmware
tmpfs           795M  4.0K  795M   1% /run/user/1000

ホストネームが正しく設定されていなかったので、以下を実行

  • /etc/cloud/cloud.cfgのpreserve_hostnameをtrueにする
    • preserve_hostname: true
  • hostnamectlからhostnameを変更
sudo hostnamectl set-hostname yourhostname

参考
https://zenn.dev/usagi1975/articles/2023-12-29-000_raspi5_boot_nvme
https://zenn.dev/yuyakato/articles/82383b8c8869d3

shuntakashuntaka

Pod配備予定サービス一覧

サービス名 役割
Harbor コンテナレジストリ
このスクラップは2ヶ月前にクローズされました