Raspberry Pi Desktop (for PC and Mac)のおすすめ初期設定
【目次】
- システムの更新
- タイムゾーンとロケール
- NTPによる時刻合わせの有効化
- システムの自動更新
- SSH キーの再生成
- 日本語入力の設定
- 使用しないソフトウェアの削除例
- /etc/rsyslog.conf でのログ出力の抑止
- 運用保守用ツール net-tools, pciutils のインストール
サイト内の関連 Web ページ:
- インストール手順は、「Raspberry Pi Desktop (for PC and Mac) のインストール」のページで説明している.
- 「Raspberry Pi Desktop (for PC and Mac) で基本ソフトウェア類のインストール」については,別のウェブページで説明している.
システムの更新
配布されているイメージは 2022年7月1日版であり,インストール直後の状態では多数の更新が未適用である.端末(ターミナル)を開き,次のコマンドを実行.
# パッケージリストの情報を更新
sudo apt update
sudo apt -yV upgrade
sudo apt -yV dist-upgrade
sudo apt -yV autoremove
sudo apt autoclean
rpi-update は Raspberry Pi 本体のファームウェアとカーネルを更新するコマンドであり,PC/Mac 版では実行しない.
実行結果例
更新の完了後,システムを再起動する.端末(ターミナル)で,次のコマンドを実行.
sudo shutdown -r now
タイムゾーンとロケール
タイムゾーンを日本標準時に設定する.端末(ターミナル)で,次のコマンドを実行.
sudo timedatectl set-timezone Asia/Tokyo
timedatectl status
日本語ロケールを生成し,システム既定のロケールに設定する.端末(ターミナル)で,次のコマンドを実行.
sudo sed -i 's/^# *ja_JP.UTF-8 UTF-8/ja_JP.UTF-8 UTF-8/' /etc/locale.gen
sudo locale-gen
sudo update-locale LANG=ja_JP.UTF-8
設定はログインし直した後に反映される.
実行結果例
NTPによる時刻合わせの有効化
Debian 11 では systemd-timesyncd による時刻同期が標準である.端末(ターミナル)で,次のコマンドを実行.
sudo apt -y install systemd-timesyncd
sudo timedatectl set-ntp true
timedatectl status
timedatectl status の出力で「System clock synchronized: yes」「NTP service: active」と表示されれば有効である.
参照する NTP サーバを国内のものに変更する場合は,/etc/systemd/timesyncd.conf の NTP= 行を設定する.端末(ターミナル)で,次のコマンドを実行.
sudo sed -i 's/^#*NTP=.*/NTP=ntp.nict.jp/' /etc/systemd/timesyncd.conf
sudo systemctl restart systemd-timesyncd
timedatectl show-timesync --all
システムの自動更新
セキュリティ更新を自動で適用する unattended-upgrades を導入する.端末(ターミナル)で,次のコマンドを実行.
# パッケージリストの情報を更新
sudo apt update
sudo apt -y install unattended-upgrades
自動実行を有効にするため,/etc/apt/apt.conf.d/20auto-upgrades を設定する.端末(ターミナル)で,次のコマンドを実行.
echo 'APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";' | sudo tee /etc/apt/apt.conf.d/20auto-upgrades
sudo systemctl status unattended-upgrades
実行結果例
SSH キーの再生成
配布イメージやクローンした仮想マシンでは,SSH のホスト鍵が他の環境と重複することがある.重複を避けるため,ホスト鍵を再生成する.端末(ターミナル)で,次のコマンドを実行.
sudo rm -f /etc/ssh/ssh_host*
sudo dpkg-reconfigure openssh-server
実行結果例
日本語入力の設定
入力メソッドフレームワーク fcitx と日本語入力エンジン Mozc を導入する.端末(ターミナル)で,次のコマンドを実行.
# パッケージリストの情報を更新
sudo apt update
sudo apt -y install fcitx fcitx-mozc fcitx-config-gtk
im-config -n fcitx
設定を反映するため,システムを再起動する.端末(ターミナル)で,次のコマンドを実行.
sudo shutdown -r now
再起動後,入力メソッドの一覧に Mozc を追加する.端末(ターミナル)で,次のコマンドを実行.
sed -i "/EnabledIMList/s/mozc:False/mozc:True/g" ~/.config/fcitx/profile
fcitx-configtool
日本語入力のオン・オフは,既定では Ctrl + Space で切り替える.
実行結果例
使用しないソフトウェアの削除例
ディスク使用量を減らしたい場合の削除例である.削除するとそのソフトウェアは使用できなくなるため,必要なものが含まれていないか確認してから実行する.端末(ターミナル)で,次のコマンドを実行.
sudo apt -y purge libreoffice*
sudo apt -yV autoremove
sudo apt autoclean
日本語入力を使用しない場合の削除例である.端末(ターミナル)で,次のコマンドを実行.
sudo apt -y purge mozc-server mozc-data mozc-utils-gui
sudo apt -y purge fcitx fcitx-data fcitx-bin fcitx-modules
sudo apt -yV autoremove
sudo apt autoclean
/etc/rsyslog.conf でのログ出力の抑止
ディスクへの書き込みを減らす目的で,rsyslog による一部のログファイル出力を停止する設定である.障害の調査が困難になるため,必要な場合にのみ行う.systemd のジャーナル(journalctl)でのログ参照は引き続き可能である.
端末(ターミナル)で,次のコマンドを実行.
sudo cp /etc/rsyslog.conf /etc/rsyslog.conf.DIST
sudo rm -f /tmp/1
cat /etc/rsyslog.conf | sed 's/^auth/#auth/g' | sed 's/^daemon/#daemon/g' | sed 's/^kern/#kern/g' | sed 's/^lpr/#lpr/g' | sed 's/^user/#user/g' | sed 's/^mail/#mail/g' > /tmp/1
sudo cp /tmp/1 /etc/rsyslog.conf
sudo systemctl restart rsyslog
元に戻す場合は,退避したファイルを書き戻す.端末(ターミナル)で,次のコマンドを実行.
sudo cp /etc/rsyslog.conf.DIST /etc/rsyslog.conf
sudo systemctl restart rsyslog
運用保守用ツール net-tools, pciutils のインストール
ネットワーク設定を表示する ifconfig(net-tools)や,PCI デバイスを表示する lspci(pciutils)を導入する.端末(ターミナル)で,次のコマンドを実行.
sudo apt -y install net-tools pciutils