LoginSignup
0
0

RaspberryPiを連続稼働で設定するためのメモ

Posted at

Raspberry Piを連続稼働させるための設定をしたのでメモ

環境

Raspberry Pi4
microSD 8GB
有線LAN

参考

Rasbianのインストール

環境としてRasbianを使用する。
Raspberry Pi Imagerを使ってRasbian OS Lite 64bitをインストールする。
パッケージを最新化する。

sudo apt update -y
sudo apt upgrade -y

Swap機能の抑止

SWAPの読み書きが発生するとSDカードの書き込み回数を消費してしまうので、無効化する。

sudo apt autoremove -y dphys-swapfile

テンポラリディレクトリのRAMディスク化

テンポラリディレクトリをメモリ上に展開することで、SDカードの書き込み回数を削減する。
テンポラリなので、電源断で消えてもいいはず。

/etc/fstabに以下の定義行を追加

tmpfs           /tmp            tmpfs   defaults,size=256m,noatime,mode=1777      0       0
tmpfs           /var/tmp        tmpfs   defaults,size=16m,noatime,mode=1777      0       0
tmpfs           /var/log        tmpfs   defaults,size=32m,noatime,mode=0755

追加したら、再起動して設定を反映させる。

reboot

再起動後にdfコマンドでマウントできていることを確認します。

$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev             1672432       0   1672432   0% /dev
tmpfs             388432    5980    382452   2% /run
/dev/mmcblk0p2   7072624 2017408   4676144  31% /
tmpfs            1942152       0   1942152   0% /dev/shm
tmpfs               5120      16      5104   1% /run/lock
tmpfs             262144       0    262144   0% /tmp
tmpfs              32768       8     32760   1% /var/log
tmpfs              16384       0     16384   0% /var/tmp
/dev/mmcblk0p1    522232   62394    459838  12% /boot/firmware
tmpfs             388428       0    388428   0% /run/user/1000
0
0
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
0
0