Raspberry PiにUbuntuをインストールし、デスクトップ環境を構築する際のメモ。
本文章での前提条件・考慮事項は次のとおり。
- Raspberry Pi 5 (8GB)
- Ubuntu Desktop 23.10 (64 bit)
- Raspberry Pi Imagerで作成したイメージを使用してインストール
- ある程度の長期間、連続動作することを考慮して設定
初回起動までのインストール手順、個別のソフトウェアの設定等については省略しているため、適宜Ubuntu 24.04のインストールを参照のこと。
初期設定
必需ツール類のインストール
以下のコマンドで一括してインストールする。 インストール目的等については省略。
$sudo apt install curl git rsync tree
ここでインストールする各パッケージの概要は次のとおり。
パッケージ名 | 概要 |
---|---|
curl
|
URL 文法でデータを転送するコマンドラインツール |
git
|
速く、スケーラブルな分散型リビジョン管理システム |
rsync
|
高速で多目的なリモート (兼ローカル) ファイル複製ツール |
tree
|
displays an indented directory tree, in color |
パッケージ名 | 概要 |
dotfiles
これはごく個人的な設定をまとめたものであるため、そのまま使用することは推奨しない。
$git clone --depth 1 https://github.com/smdn/smdn.git smdn-dotfiles $smdn-dotfiles/etc/home/smdn/deploy-dotfiles.sh
スワップの無効化
スワップ頻度の最小化
ここではスワップ頻度を0
に設定する。 なお現在の設定値はcat /proc/sys/vm/swappiness
で確認できる。
/etc/sysctl.conf
に以下の内容を追記する。
vm.swappiness = 0
sysctl -p
で変更を反映させる。 また、正しく変更されたかを確認。
$cat /proc/sys/vm/swappiness 60 $sudo sysctl -p vm.swappiness = 0 $cat /proc/sys/vm/swappiness 0
スワップファイルの無効化
systemdによって管理されているスワップファイルを無効化する。
まず、systemdによって管理されているスワップファイルの状態を確認する。
$systemctl status --type swap
● swapfile.swap - The default swapfile
Loaded: loaded (/usr/lib/systemd/system/swapfile.swap; enabled; preset: enabled)
Active: active since Fri 2024-06-21 12:16:51 JST; 1h 54min ago
What: /swapfile
Tasks: 0 (limit: 9073)
Memory: 472.0K (peak: 1.5M)
CPU: 12ms
CGroup: /system.slice/swapfile.swap
6月 21 12:16:51 rpi5 systemd[1]: Activating swap swapfile.swap - The default swapfile...
6月 21 12:16:51 rpi5 systemd[1]: Activated swap swapfile.swap - The default swapfile.
上記のように、systemdユニットswapfile.swap
がスワップファイル/swapfile
を管理している。 そこで、このswapfile.swap
をmask(無効化)する。
$sudo systemctl mask swapfile.swap Created symlink /etc/systemd/system/swapfile.swap → /dev/null. $systemctl status --type swap ● swapfile.swap Loaded: masked (Reason: Unit swapfile.swap is masked.) Active: active since Fri 2024-06-21 12:16:51 JST; 2h 3min ago CPU: 12ms CGroup: /system.slice/swapfile.swap 6月 21 12:16:51 rpi5 systemd[1]: Activating swap swapfile.swap - The default swapfile... 6月 21 12:16:51 rpi5 systemd[1]: Activated swap swapfile.swap - The default swapfile.
この時点でのswapfile.swap
は、maskされてはいるが、状態は引き続きactiveのままとなる。
再起動後、再度確認して無効化されたことを確認する。
$systemctl status --type swap 何も表示されない $swapon --show 何も表示されない $cat /proc/swaps Filename Type Size Used Priority 何も表示されない
NTPサーバーの設定
systemd-timesyncd
の設定を確認すると、初期設定ではntp.ubuntu.com
と同期するようになっている。
(systemctl status
でStatusを確認すると、ntp.ubuntu.com
に接続したことが確認できる)
$systemctl status systemd-timesyncd
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-03-16 22:32:41 JST; 12min ago
Docs: man:systemd-timesyncd.service(8)
Main PID: 557 (systemd-timesyn)
Status: "Contacted time server 91.189.91.157:123 (ntp.ubuntu.com)."
Tasks: 2 (limit: 9117)
Memory: 1.4M
CPU: 67ms
CGroup: /system.slice/systemd-timesyncd.service
└─557 /lib/systemd/systemd-timesyncd
/etc/systemd/timesyncd.conf
を編集して、NTPサーバーを設定する。 ここではNICTの公開NTPサーバーであるntp.nict.jpを使用する。
[Time]
NTP=ntp.nict.jp
設定を変更したら、再起動する。 少し時間が経過してからstatusを確認すると、設定を反映した動作になっているか確認することができる。
$sudo systemctl restart systemd-timesyncd.service $systemctl status systemd-timesyncd ● systemd-timesyncd.service - Network Time Synchronization Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled) Active: active (running) since Sat 2024-03-16 22:52:03 JST; 48s ago Docs: man:systemd-timesyncd.service(8) Main PID: 6407 (systemd-timesyn) Status: "Contacted time server 133.243.238.163:123 (ntp.nict.jp)." Tasks: 2 (limit: 9117) Memory: 1.2M CPU: 61ms CGroup: /system.slice/systemd-timesyncd.service └─6407 /lib/systemd/systemd-timesyncd
systemd timerユニットの停止
systemdのタイマーユニットのうち、不要なものを停止・無効化する。
まずは、登録・動作しているタイマーユニットを確認する。 systemctl list-timers --all
で一覧表示できる。
$systemctl list-timers --all
NEXT LEFT LAST PASSED UNIT ACTIVATES >
Sat 2024-03-16 22:21:45 JST 7min left - - systemd-tmpfiles-clean.timer systemd-tmpfiles-cle>
Sat 2024-03-16 22:33:50 JST 19min left Sat 2024-03-16 21:32:47 JST 41min ago anacron.timer anacron.service
Sat 2024-03-16 22:37:35 JST 23min left Sat 2024-03-16 16:02:17 JST 6h ago fwupd-refresh.timer fwupd-refresh.service
Sun 2024-03-17 00:00:00 JST 1h 45min left Sat 2024-03-16 13:43:41 JST 8h ago dpkg-db-backup.timer dpkg-db-backup.servi>
Sun 2024-03-17 00:00:00 JST 1h 45min left Sat 2024-03-16 13:43:41 JST 8h ago logrotate.timer logrotate.service
Sun 2024-03-17 00:40:45 JST 2h 26min left Sat 2024-03-16 14:46:16 JST 7h ago apt-daily.timer apt-daily.service
Sun 2024-03-17 03:10:42 JST 4h 56min left Sat 2024-03-16 13:43:41 JST 8h ago e2scrub_all.timer e2scrub_all.service
Sun 2024-03-17 03:57:52 JST 5h 43min left Sat 2024-03-16 14:32:25 JST 7h ago motd-news.timer motd-news.service
Sun 2024-03-17 06:00:06 JST 7h left Sat 2024-03-16 13:49:20 JST 8h ago apt-daily-upgrade.timer apt-daily-upgrade.se>
Sun 2024-03-17 08:44:52 JST 10h left Sat 2024-03-16 14:46:29 JST 7h ago man-db.timer man-db.service
Sun 2024-03-17 11:12:54 JST 12h left Thu 2023-10-12 08:06:21 JST 5 months 4 days ago update-notifier-motd.timer update-notifier-motd>
Sun 2024-03-17 22:11:51 JST 23h left Sat 2024-03-16 22:11:51 JST 2min 34s ago update-notifier-download.timer update-notifier-down>
Mon 2024-03-18 01:15:48 JST 1 day 3h left Sat 2024-03-16 13:46:29 JST 8h ago fstrim.timer fstrim.service
- - - - apport-autoreport.timer apport-autoreport.se>
- - - - snapd.snap-repair.timer snapd.snap-repair.se>
- - - - ua-timer.timer ua-timer.service
16 timers listed.
ここでは、以下を停止する。
- apt-daily.timer
- apt-daily-upgrade.timer
- motd-news.timer
- man-db.timer
- update-notifier-motd.timer
systemctl stop
およびsystemctl disable
コマンドで、上記タイマーユニットを停止する。
$sudo systemctl stop apt-daily.timer $sudo systemctl disable apt-daily.timer $sudo systemctl stop apt-daily-upgrade.timer $sudo systemctl disable apt-daily-upgrade.timer $sudo systemctl stop motd-news.timer $sudo systemctl disable motd-news.timer $sudo systemctl stop man-db.timer $sudo systemctl disable man-db.timer $sudo systemctl stop update-notifier-motd.timer $sudo systemctl disable update-notifier-motd.timer
コンソール画面のフォントとフォントサイズを調整する
/etc/default/console-setup
を編集して、FONTFACE
およびFONTSIZE
を変更する。
-FONTFACE="Fixed"
-FONTSIZE="8x16"
+FONTFACE="Terminus"
+FONTSIZE="16x32"
FONTFACE
およびFONTSIZE
に設定できる値とその組み合わせは、man 5 console-setupで確認することができる。
設定の変更を反映する。 下記コマンドを実行すると、コンソール画面が新しいフォントとフォントサイズで再表示される。
$sudo service console-setup restart
再起動後も有効にするために、initramfsを更新する。
$sudo update-initramfs -u -k all
不要なaptパッケージの削除
以下のコマンドで一括して削除する。 削除理由等については省略。
sudo apt purge \
aisleriot \
aspell aspell-en \
'^avahi-.*' \
brltty \
cheese '^cheese-.*' \
cups cups-browsed cups-bsd cups-client cups-common cups-core-drivers cups-daemon cups-filters* cups-ipp-utils cups-pk-helper cups-server-common foomatic-db-compressed-ppds ipp-usb \
enchant-2 \
'^espeak(-.*)?' \
fonts-liberation '^fonts-liberation-.*' \
ftp tnftp \
gamemode gamemode-daemon \
gnome-calendar gnome-mahjongg gnome-mines gnome-sudoku \
hplip hplip-data '^printer-driver-.*' \
'^libreoffice-.*' \
modemmanager \
mythes-en-au mythes-en-us \
ntfs-3g '^libntfs-.*' \
nano \
openprinting-ppds \
ppp pptp-linux \
rygel \
rhythmbox '^rhythmbox-.*' \
sane-utils sane-airscan libsane-hpaio \
simple-scan \
shotwell '^shotwell-.*' \
speech-dispatcher speech-dispatcher-audio-plugins \
system-config-printer-common system-config-printer-udev \
transmission-gtk transmission-common \
totem totem-common totem-plugins \
thunderbird thunderbird-gnome-support '^thunderbird-locale-.*' \
wamerican wbritish
ここで削除する各パッケージの概要は次のとおり。
パッケージ名 | 概要 |
---|---|
aisleriot
|
GNOME ソリティアカードゲーム集 |
aspell
|
GNU aspell スペルチェッカ |
aspell-en
|
GNU Aspell 用英語辞書 |
'^avahi-.*'
|
Avahi IPv4LL ネットワークアドレス設定デーモン |
brltty
|
点字ディスプレイを使う視覚障害者のためのアクセスソフトウェア |
cheese
|
ウェブカムで写真や動画を撮影するツール |
'^cheese-.*'
|
Common files for the Cheese tool to take pictures and videos |
cups
|
Common UNIX Printing System(tm) - PPD/ドライバサポート、web インターフェース |
cups-browsed
|
OpenPrinting CUPS フィルター - cups-browsed |
cups-bsd
|
Common UNIX Printing System(tm) - BSD commands |
cups-client
|
Common UNIX Printing System(tm) - クライアントプログラム (SysV) |
cups-common
|
Common UNIX Printing System(tm) - common files |
cups-core-drivers
|
Common UNIX Printing System(tm) - driverless printing |
cups-daemon
|
Common UNIX Printing System(tm) - daemon |
cups-filters*
|
OpenPrinting CUPS フィルタ - メインパッケージ |
cups-ipp-utils
|
Common UNIX Printing System(tm) - IPP developer/admin utilities |
cups-pk-helper
|
cups の細かい権限設定を行なうための PolicyKit ヘルパー |
cups-server-common
|
Common UNIX Printing System(tm) - server common files |
foomatic-db-compressed-ppds
|
OpenPrinting プリンタサポート - データベースから派生した圧縮 PPD |
ipp-usb
|
Daemon for IPP over USB printer support |
enchant-2
|
各種スペルチェッカエンジンへのラッパー (バイナリプログラム) |
'^espeak(-.*)?'
|
speech data files |
fonts-liberation , ^fonts-liberation-.* |
Times, Arial および Courier と同等のメトリックのフォント群 |
ftp
|
dummy transitional package for tnftp |
tnftp
|
enhanced ftp client |
gamemode
|
Optimise Linux system performance on demand |
gamemode-daemon
|
Optimise Linux system performance on demand (daemon) |
gnome-calendar
|
GNOME 用カレンダーアプリケーション |
gnome-mahjongg
|
classic Eastern tile game for GNOME |
gnome-mines
|
popular minesweeper puzzle game for GNOME |
gnome-sudoku
|
Sudoku puzzle game for GNOME |
hplip
|
HP Linux Printing and Imaging System (HPLIP) |
hplip-data
|
HP Linux Printing and Imaging - データファイル |
'^printer-driver-.*'
|
printer driver for HP-GDI printers |
'^libreoffice-.*'
|
office productivity suite -- word processor |
modemmanager
|
モデムを管理する D-Bus サービス |
mythes-en-au
|
Australian English Thesaurus for OpenOffice.org |
mythes-en-us
|
English (USA) Thesaurus for LibreOffice |
ntfs-3g
|
FUSE 用の読み書き可能な NTFS ドライバ |
'^libntfs-.*'
|
FUSE 用 NTFS 読み書きドライバ (ランタイムライブラリ) |
nano
|
Pico にヒントを得て作られた、コンパクトで使いやすいテキストエディタ |
openprinting-ppds
|
OpenPrinting printer support - PostScript PPD files |
ppp
|
Point-to-Point Protocol (PPP) デーモン |
pptp-linux
|
Point-to-Point Tunneling Protocol (PPTP) クライアント |
rygel
|
GNOME UPnP/DLNA services |
rhythmbox
|
GNOME 用音楽プレイヤーおよびオーガナイザー |
'^rhythmbox-.*'
|
data files for rhythmbox |
sane-utils
|
スキャナ用 API ライブラリ - ユーティリティ |
sane-airscan
|
SANE backend for AirScan (eSCL) and WSD document scanner |
libsane-hpaio
|
HP の複合機用 SANE バックエンド |
simple-scan
|
シンプルなスキャンユーティリティ |
shotwell
|
デジタル写真オーガナイザ |
'^shotwell-.*'
|
digital photo organizer - common files |
speech-dispatcher
|
Common interface to speech synthesizers |
speech-dispatcher-audio-plugins
|
Audio output plugins |
system-config-printer-common
|
backend and the translation files for system-config-printer |
system-config-printer-udev
|
プリンタの自動検出と設定を行う各種ユーティリティ |
transmission-gtk
|
lightweight BitTorrent client (GTK+ interface) |
transmission-common
|
軽量な BitTorrent クライアント (共通ファイル) |
totem
|
GStreamer ベースで GNOME デスクトップ向けのシンプルなメディアプレイヤ |
totem-common
|
Totem メディアプレイヤーのデータファイル |
totem-plugins
|
Plugins for the Totem media player |
thunderbird
|
Email, RSS and newsgroup client with integrated spam filter |
thunderbird-gnome-support
|
Email, RSS and newsgroup client - GNOME support |
'^thunderbird-locale-.*'
|
Afrikaans language pack for Thunderbird |
wamerican
|
/usr/share/dict 用米国英語単語リスト |
wbritish
|
/usr/share/dict 用英国英語単語リスト |
パッケージ名 | 概要 |
削除が完了したら、クリーンアップする。
$sudo apt autoremove --purge $sudo apt autoclean -y
デスクトップ設定
システムモニタアプレットのインストール
トップバーにシステムモニタアプレットを追加する。
GNOMEのバージョンによっては、 system-monitorは未対応で動作しない場合がある。 ここでは、オリジナルの代わりとしてsystem-monitor-nextをインストールする。
まずは、依存パッケージをインストールする。
gnome-shell-extension-managerがインストールされていない場合は、インストールする $sudo apt install gnome-shell-extension-manager gnome-shell-system-monitor-appletの依存パッケージをインストールする $sudo apt install gir1.2-gtop-2.0
続いて、GNOME Shell Extension Managerを起動し、system-monitor-nextをインストールする。
インストールが完了し、トップバーにアプレットが表示されたら、設定を開いて表示内容の取捨選択・更新間隔の調整を行う。
起動時の自動ログイン
⏻メニューより⚙設定を開き、👥ユーザーを選択する。
まず、[ユーザーを追加]より、自動ログイン用の別ユーザーを作成する。 作成したら、「自動ログイン」をオンにする。 これにより、起動時に自動的にユーザーのログインが行われる。
パスワードレスのログイン
以下は未実施・未検証。 GDMのログイン画面から、パスワードレスでログインする方法について。
ロック時の認証画面の無効化
ロック時などに表示される認証画面を無効化して、パスワードレスでデスクトップに復帰できるようにする。
下記コマンドでロックスクリーンを無効化する。 これにより、⏻メニューから🔒ロックの項目も表示されなくなる。
$gsettings set org.gnome.desktop.lockdown disable-lock-screen true
サスペンド時・アイドル状態からの復帰時のロックを無効化する。
$gsettings set org.gnome.desktop.screensaver ubuntu-lock-on-suspend false $gsettings set org.gnome.desktop.screensaver idle-activation-enabled false