Technology

Raspberry Pi 4 を 外部ストレージで起動する。OSはCentOS8

投稿日:2020年7月24日 更新日:

CentoOS8 Raspberry Pi 4用イメージをダウンロード

https://people.centos.org/pgreco/CentOS-Userland-8-stream-aarch64-RaspberryPI-Minimal-4/
CentOS-Userland-8-stream-aarch64-RaspberryPI-Minimal-4-sda.raw.xz

Raspberry Pi 公式サイト OS書込みツール(Imager)

https://www.raspberrypi.org/downloads/
Raspberry Pi Imager を実行環境にあわせてダウンロード&インストール

Imagerを使って、OSイメージを書込み

外部ストレージ起動に対応したファームウェアに入れ替える

https://github.com/raspberrypi/firmware/tree/master/boot
*.elf *.dat を入れ替え

Download the updated firmware files *.elf *.dat from the master branch of the Raspberry Pi Firmware Github repo.

https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711_bootloader_config.md#usbmassstorageboot

PARTUUIDを調べる

すでに稼働中のRaspberry Piや適当なLinux, MacOSのPCに、書き込んだ外部ストレージを接続
※Windowsではどうしようもない

$ sudo blkid
/dev/mmcblk0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="xxxx-xxxx" TYPE="vfat" PARTUUID="xxxxxxxx-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="ext4" PARTUUID="xxxxxxxx-02"
/dev/sda1: SEC_TYPE="msdos" UUID="xxxx-xxxx" TYPE="vfat" PARTUUID="xxxxxxxx-01"
/dev/sda2: LABEL="_swap" UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="swap" PARTUUID="xxxxxxxx-02"
/dev/sda3: LABEL="_/" UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" TYPE="ext4" PARTUUID="xxxxxxxx-03"
/dev/mmcblk0: PTUUID="xxxxxxxx" PTTYPE="dos"

cmdline.txtを編集

$ sudo mount /dev/sda1 /mnt/

$ sudo /mnt/cmdline.txt
console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline rootwait
↓
console=ttyAMA0,115200 console=tty1 root=PARTUUID=xxxxxxxx-03 rootfstype=ext4 elevator=deadline rootwait

$ sudo umount /mnt/

fstabを編集

$ sudo mount /dev/sda3 /mnt/

$ sudo vi /mnt/etc/fstab
UUID=xxxx-xxxx  /boot vfat    defaults,noatime 0 0
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  / ext4    defaults,noatime 0 0
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  swap swap    defaults,noatime 0 0
↓
PARTUUID=xxxxxxxx-01  /boot vfat    defaults,noatime 0 0
PARTUUID=xxxxxxxx-02  swap  swap    defaults,noatime 0 0
PARTUUID=xxxxxxxx-03  /     ext4    defaults,noatime 0 0

$ sudo umount /mnt/

追加設定

vi /boot/config.txt
# HDMIなしでも起動
hdmi_force_hotplug=1
# SDカードスロットを無効
dtparam=sd_poll_once=on


-Technology
-

執筆者:

関連記事

CentOS8のリポジトリ参照先をCentOS Stream 8に変更する

CentOS Project の方針変更の発表がされました。 https://blog.centos.org/2020/12/future-is-centos-stream/ 要約すると、CentOS …

マルチタッチ検出

スマートフォン, タブレットなどタッチイベントを検出します。 DEMO window.addEventListener('load', (event) => { let e: H …

cURLでWebDAV

Basic認証でファイルのダウンロード curl –user name:password -X GET -O –url https://example.com/path/to/filename.t …

pgpool-II オンラインリカバリスクリプト の修正

課題 pgpoolに付属のオンラインリカバリスクリプトが実行できない Postgres プライマリのホスト名の名前解決ができない「レプリケーションスロット名が不正」となる 環境 CentOS7Post …

Powershellを利用してFirefoxをダウンロードしてインストールする

PowerShell3.0 で導入された Invoke-WebRequest を利用してFirefoxをダウンロードします。Start-Process に -Verb RunAs をつけるこ …