Surface Go 2 on Ubuntu Serverをサイネージにする
概要
更新履歴
- 2026/05/14 初版
- 2026/05/15 Surface UEFIで自動再起動について追記
目次
はじめに
- このドキュメントは,Surface Go 2にUbuntuをインストールした後,Surface 2 Goをサイネージに仕立てるまでの手順を説明する.
- 電源ONから自動でFirefoxをキオスクモードで起動させ,バッテリの電気量が減った場合の自動シャットダウンまでを行う.
OS関連の設定
起動モードをグラフィカルモードに変更する
- 現在のデフォルト設定がテキストモード(multi-user.target)になっているか確認.
ujpadmin@okachimachi:~$ systemctl get-default🆑
multi-user.target🈁
ujpadmin@okachimachi:~$
- テキストモードになっているので,グラフィカルモードに変更する.
ujpadmin@okachimachi:~$ sudo systemctl set-default graphical.target🆑
[sudo] password for server:🔑
Removed "/etc/systemd/system/default.target".
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.
ujpadmin@okachimachi:~$
- 電源オンするとGUIのログイン画面が起動する.
電源オン時の自動ログインとX Windowの自動起動
- Ubuntu Server環境において、LXQtのディスプレイマネージャーを使用して自動ログインにする.
- SDDM (Simple Desktop Display Manager) は、Linux などの Unix 系 OS で使われる「ディスプレイマネージャー(ログイン画面の管理プログラム)の設定を行う.
- sddm.confファイルを確認.
ujpadmin@okachimachi:~$ ls -la /etc/sddm.conf🆑
ls: cannot access '/etc/sddm.conf': No such file or directory
ujpadmin@okachimachi:~$
- ファイルがないので,次の様にファイルを作成する.
ujpadmin@okachimachi:~$ sudo vi /etc/sddm.conf🆑
ujpadmin@okachimachi:~$ cat /etc/sddm.conf🆑
[Autologin]
User=signage
Session=lxqt.desktop
ujpadmin@okachimachi:~$
- この場合,signageというOSユーザでログインする.
- ディスプレイマネージャの自動起動を有効にする.
ujpadmin@okachimachi:~$ sudo systemctl enable sddm🆑
[sudo] password for server:
Synchronizing state of sddm.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable sddm
ujpadmin@okachimachi:~$
- サイネージを安定運用するために画面の消灯(スリープ)やクラッシュ時の警告ポップアップを抑制する設定を行う.
ujpadmin@okachimachi:~$ ls -la ~/.config/autostart/disable-screen-saver.desktop🆑
ls: cannot access '/home/server/.config/autostart/disable-screen-saver.desktop': No such file or directory
ujpadmin@okachimachi:~$ vi ~/.config/autostart/disable-screen-saver.desktop🆑
ujpadmin@okachimachi:~$ cat ~/.config/autostart/disable-screen-saver.desktop🆑
[Desktop Entry]
Type=Application
Name=Disable Screen Saver
Exec=xset s off -dpms
NoDisplay=true
ujpadmin@okachimachi:~$
Firefoxの設定
Firefoxをkioskモードで自動起動する
- LXQtの自動起動(Autostart)の仕組みを利用して、ログイン直後にFirefoxをkioskモード(全画面・ツールバー非表示・F11キー等での解除不可)で立ち上げる.
ujpadmin@okachimachi:~$ mkdir -p ~/.config/autostart🆑
ujpadmin@okachimachi:~$ vi ~/.config/autostart/firefox-kiosk.desktop🆑
ujpadmin@okachimachi:~$ cat ~/.config/autostart/firefox-kiosk.desktop🆑
[Desktop Entry]
Type=Application
Name=Firefox Kiosk
Exec=firefox --kiosk https://www.google.com
NoDisplay=true
X-LXQt-Need-Tray=false
ujpadmin@okachimachi:~$
- この状態で,www.google.comが開かれる.
Firefoxのクラッシュ再起動時の通知バーを無効化
- 予期せぬ電源断などの後、再起動した際に「セッションを復元しますか?」という通知バーで画面が隠れるのを防ぐ.
- Firefoxを一度通常起動し,アドレスバーに about:config と入力.
- 検索窓に browser.sessionstore.resume_from_crash と入力.
- 値を false に変更.
そのほか微調整
- ここまでで基本的なサイネージの動作に必要な調整はできたので,こだわりの?設定をしていく.
マウスカーソルを消す
- サイネージを表示している時に,マウスカーソルが表示されるので,これを消す.
- LXQt環境)のデジタルサイネージでマウスカーソルを隠すにはunclutterという定番のツールを使用する.
ujpadmin@okachimachi:~$ sudo apt install -y unclutter🆑
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
ー略ー
- LXQtの自動起動に登録する
ujpadmin@okachimachi:~$ vi ~/.config/autostart/unclutter.desktop🆑
ujpadmin@okachimachi:~$ cat ~/.config/autostart/unclutter.desktop🆑
[Desktop Entry]
Type=Application
Name=Hide Mouse Cursor
Exec=unclutter -idle 3 -root
NoDisplay=true
ujpadmin@okachimachi:~$
- 次の様な意味.
- -idle 3: マウスが止まってから 3秒後 にカーソルを消去
- -root: 画面上のすべてのウィンドウ(Firefoxの画面など)の最前面で強制的にカーソルを消去
- 今すぐ消えるか確認.
ujpadmin@okachimachi:~$ DISPLAY=:0 unclutter -idle 3 -root &🆑
[1] 32821
ujpadmin@okachimachi:~$
- マウスを動かして3秒以上経過したら表示が消えれば成功.
サイネージパソコンからメールを送信できる様にする
- メールコマンドが使えるか確認.
ujpadmin@okachimachi:~$ mail🆑
Command 'mail' not found, but can be installed with:
sudo apt install mailutils🈁ujpadmin@okachimachi:~$
- インストールされてないので,mailutilsパッケージをインストールする.
ujpadmin@okachimachi:~$ sudo apt install mailutils🆑
[sudo] password for server:🔑
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
- インストールが進むと次の様な画面が表示される.
- 次の様な選択肢.
- Please select the mail server configuration type that best meets your needs. ニーズに最適なメールサーバー構成タイプを選択してください。
- No configuration: 構成なし:
- Should be chosen to leave the current configuration unchanged.
- 現在の構成を変更せずにそのまま使用する場合は、こちらを選択してください。
- Internet site:インターネットサイト:
- Mail is sent and received directly using SMTP.
- メールはSMTPを使用して直接送受信されます。
- Internet with smarthost: スマートホスト付きインターネット
- Mail is received directly using SMTP or by running a utility such as fetchmail. Outgoing mail is sent using a smarthost.
- メールはSMTPを使用して直接受信するか、fetchmailなどのユーティリティを実行して受信します。送信メールはスマートホストを使用して送信されます。
- Satellite system: :サテライトシステム
- All mail is sent to another machine, called a 'smarthost', for delivery.
- すべてのメールは「スマートホスト」と呼ばれる別のマシンに送信され、そこから配信されます。
- Local only: :ローカルのみ:
- The only delivered mail is the mail for local users. There is no network.
- 配信されるメールはローカルユーザー宛のメールのみです。ネットワークは使用されません。
- General mail configuration type:一般的なメール構成タイプ:
- No configuration 構成なし
- Internet Site インターネットサイト
- Internet with smarthost スマートホスト付きインターネット
- Satellite systemサテライトシステム
- Local only ローカルのみ
- インターネット経由で送信するので,Internet Siteを選択.
- ホスト名のままにする.
ー略ー
info: Selecting GID from range 100 to 999 ...
info: Adding group `postfix' (GID 118) ...
info: Selecting UID from range 100 to 999 ...
info: Adding system user `postfix' (UID 114) ...🈁
info: Adding new user `postfix' (UID 114) with group `postfix' ...
info: Not creating home directory `/var/spool/postfix'.
Creating /etc/postfix/dynamicmaps.cf🈁
info: Selecting GID from range 100 to 999 ...
info: Adding group `postdrop' (GID 119) ...
setting myhostname: okachimachi
setting alias maps
setting alias database
mailname is not a fully qualified domain name. Not changing /etc/mailname.
setting destinations: $myhostname, okachimachi, localhost.localdomain, , localhost
setting relayhost:
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all
setting inet_protocols: all
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.
Postfix (main.cf)🈁 is now set up with a default configuration. If you need to
make changes, edit /etc/postfix/main.cf (and others) as needed. To view
Postfix configuration values, see postconf(1).
After modifying main.cf, be sure to run 'systemctl reload postfix'.
ー略ー
- postfixユーザが作成され,設定ファイルも配置された.
- mailコマンドでメールを送信する.
ujpadmin@okachimachi:~$ echo "これはサイネージからのテストメールです。" | mail -s "サイネージ通知テスト" mailtest@xxxx.co.jp🆑
ujpadmin@okachimachi:~$
-
メールログを確認.
postfix/smtp[25759]: BD266181BDA: to=<受信メアド>, relay=リレーサーバ[xxx.xxx.xxx.xxx]:25, delay=0.88, delays=0.07/0.03/0.69/0.1,
dsn=5.5.2, status=bounced (host メールサーバ[xxx.xxx.xxx.xxx] said: 504 5.5.2 <okachimachi>:
Helo command rejected: need fully-qualified hostname (in reply to RCPT TO command))
- メールが送信できなかった.
- この場合,送信先のメールサーバーがセキュリティ上のルールとして、送信元が「ドメイン名を含んだ正しいホスト名(FQDN。例: okachimachi.example.com)」を名乗ることを要求している.
- Postfixのsmtp_helo_nameパラメータを設定することでメール送信時だけは「ドメイン形式のホスト名」を強制的に名乗らせる.
ujpadmin@okachimachi:~$ sudo vi /etc/postfix/main.cf🆑
ujpadmin@okachimachi:~$ grep smtp_helo_name /etc/postfix/main.cf🆑
smtp_helo_name = okachimachi.送信元ドメイン
ujpadmin@okachimachi:~$
- 設定を反映させる.
ujpadmin@okachimachi:~$ sudo systemctl restart postfix🆑
ujpadmin@okachimachi:~$
- 修正後,メールを送信する.
ujpadmin@okachimachi:~$ echo "HELO名の修正テストです。" | mail -s "HELO修正テスト" mailtest@xxxx.co.jp
ujpadmin@okachimachi:~$
- ログを確認する.
ujpadmin@okachimachi:~$ tail /var/log/mail.log🆑
2026-05-13T16:09:55.251365+09:00 okachimachi postfix/pickup[29249]: 3CA4B18219B: uid=1000 from=<ujpadmin@okachimachi>
2026-05-13T16:09:55.278345+09:00 okachimachi postfix/cleanup[29377]: 3CA4B18219B: message-id=<20260513070955.3CA4B18219B@okachimachi>
2026-05-13T16:09:55.282728+09:00 okachimachi postfix/qmgr[29250]: 3CA4B18219B: from=<ujpadmin@okachimachi>, size=378, nrcpt=1 (queue active)
2026-05-13T16:09:56.699768+09:00 okachimachi postfix/smtp[29384]: 3CA4B18219B: to=<mailtest@xxxx.co.jp>,
relay=メールサーバ[xxx.xxx.xxx.xxx]:25, delay=1.5, delays=0.08/0.04/0.3/1.1, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as CB784639C6B2)
2026-05-13T16:09:56.702499+09:00 okachimachi postfix/qmgr[29250]: 3CA4B18219B: removed
ujpadmin@okachimachi:~$
- リレーできたので送信できた.
自動再起動の設定と起動時にメールを送信する様にする
- 運用を確実にするために,毎日OSを再起動させる.
- rootユーザでログインし,指定された時間に再起動を行う..
ujpadmin@okachimachi:~$ su - root🆑
Password:🔑
root@okachimachi:~# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
1 3 * * * /sbin/shutdown -r now🈁
root@okachimachi:~#
- これで朝3時1分にOSが自動再起動する.
- サイネージユーザでログインが完了したらメールを送る様に設定する.
ujpadmin@okachimachi:~$ crontab -l🆑
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').
#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
@reboot sleep 30 && echo "サイネージユーザーがログインし、稼働を開始しました。" | mail -s "【通知】サイネージログイン完了" mailtest@xxxx.co.jp🈁
ujpadmin@okachimachi:~$
- @rebootを指定することで,OSが起動した後に自動ログインが成功したらメールが送信される.
バッテリ稼働になったらメールを送り,10%以下になったらシャットダウンする
- ACアダプタが外れた場合,バッテリーの充電レベルが低下した場合にメールを送信するよう,次の様な仕様の仕組みを入れる.
- UEFIでBattely LimitをEnabledにしているので最大50%までしか充電されない前提.
- 5分に1回バッテリ状態を検知.
- ACアダプタが取り外されたら通知.
- バッテリの電気量が45%以下まで減ったら通知.
- Battely Limit設定後のバッテリ劣化も加味している.
- 45%以下の場合,5分おきにメールを送信.
- バッテリーの電気量が10%以下になったらシャットダウンする.
- 過放電でバッテリーを痛めないため.
- スクリプト配置するディレクトリを作成.
ujpadmin@okachimachi:~$ mkdir -p ~/scripts🆑
ujpadmin@okachimachi:~$
-
スクリプトを作成.
ujpadmin@okachimachi:~$ vi ~/scripts/power_monitor.sh🆑
次の様なスクリプトを保存する.スクリプト中のメアドは自分用に変更する.
#!/bin/bash
# 通知先メールアドレス
MAIL_TO="通知用のメールアドレス"
# 状態記録用ファイルのパス
STATUS_FILE="/tmp/power_last_status"
LAST_ALERT_FILE="/tmp/power_last_alert_time"
# 初期ファイルの作成(存在しない場合)
[ ! -f "$STATUS_FILE" ] && echo "Unknown" > "$STATUS_FILE"
[ ! -f "$LAST_ALERT_FILE" ] && echo "0" > "$LAST_ALERT_FILE"
while true; do
# Surfaceの実機に合わせた電源状態とバッテリー残量の取得
AC_STATUS=$(cat /sys/class/power_supply/ACAD/online) # 1:AC接続, 0:バッテリー駆動
BAT_LEVEL=$(cat /sys/class/power_supply/BAT1/capacity)
LAST_STATUS=$(cat "$STATUS_FILE")
CURRENT_TIME=$(date +%s)
# --- 1. 急を要するバッテリー10%以下のシャットダウン処理 ---
if [ "$BAT_LEVEL" -le 10 ]; then
echo "【致命的】バッテリーが10%以下(現在: ${BAT_LEVEL}%)になったため、システムを守るために自動シャットダウンします。" | mail -s "【重要】サイネージ 強制シャットダウン" "$MAIL_TO"
sleep 5
sudo /sbin/shutdown -h now
exit 0
fi
# --- 2. ACアダプタ着脱の即時監視 ---
if [ "$AC_STATUS" -eq 0 ] && [ "$LAST_STATUS" != "Battery" ]; then
echo "【警告】SurfaceのACアダプタが外れました。バッテリー駆動に切り替わりました。(残量: ${BAT_LEVEL}%)" | mail -s "【警告】サイネージ AC切断" "$MAIL_TO"
echo "Battery" > "$STATUS_FILE"
elif [ "$AC_STATUS" -eq 1 ] && [ "$LAST_STATUS" != "AC" ]; then
echo "【通知】ACアダプタが接続されました。給電を開始します。(残量: ${BAT_LEVEL}%)" | mail -s "【通知】サイネージ AC接続" "$MAIL_TO"
echo "AC" > "$STATUS_FILE"
echo "0" > "$LAST_ALERT_FILE" # AC接続時はアラートタイマーをリセット
fi
# --- 3. バッテリー残量45%以下の5分おき通知(バッテリー駆動時のみ) ---
if [ "$AC_STATUS" -eq 0 ] && [ "$BAT_LEVEL" -le 45 ]; then
LAST_ALERT_TIME=$(cat "$LAST_ALERT_FILE")
# 前回のメール送信から300秒(5分)以上経っているか確認
if [ $((CURRENT_TIME - LAST_ALERT_TIME)) -ge 300 ]; then
echo "【注意】バッテリー残量が45%以下です(現在: ${BAT_LEVEL}%)。ACアダプタが外れたままの可能性があります。" | mail -s "【注意】サイネージ バッテリー低下アラート(${BAT_LEVEL}%)" "$MAIL_TO"
echo "$CURRENT_TIME" > "$LAST_ALERT_FILE"
fi
fi
# 60秒ごとにチェック
sleep 60
done
- 作成したスクリプトに実行権限を付与.
chmod +x ~/scripts/power_monitor.sh🆑
一般ユーザーへのshutdown権限付与
- スクリプト内でshutdownをしているので,サイネージ用のユーザIDに対してパスワード不要でシャットダウンする権限を付与する.
ujpadmin@okachimachi:~$ sudo vi /etc/sudoers.d/signage-shutdown🆑
ujpadmin@okachimachi:~$ cat /etc/sudoers.d/signage-shutdown🆑
signage ALL=(ALL) NOPASSWD: /sbin/shutdown
ujpadmin@okachimachi:~$
- この場合,signageユーザに権限が付与される.
作成したスクリプトを自動起動にする
作成したスクリプトが,サイネージ用のユーザがログインしたタイミングで常に動き続ける様に,LXQtの自動起動(Autostart)に追加する.
ujpadmin@okachimachi:~$ vi ~/.config/autostart/power-monitor.desktop🆑
ujpadmin@okachimachi:~$ cat ~/.config/autostart/power-monitor.desktop🆑
[Desktop Entry]
Type=Application
Name=Power Monitor
Exec=/home/signage/cripts/power_monitor.sh
NoDisplay=true
ujpadmin@okachimachi:~$
再起動して動作確認を行う
サイネージ用のユーザIDで再起動ができるか確認.
ujpadmin@okachimachi:~$ sudo reboot🆑
[sudo] password for server:
Broadcast message from root@okachimachi on pts/1 (Thu 2026-05-14 00:40:46 JST):
The system will reboot now!
ujpadmin@okachimachi:~$ Connection to 192.168.20.290 closed by remote host.
再起動したら,ログインしてバッテリモニタリングのプロセスが稼働しているか確認.
ujpadmin@okachimachi:~$ ps -ef|grep power_monitor.sh🆑
2042 1944 0 00:41 ? 00:00:00 /bin/bash /home/server/scripts/power_monitor.shujpadmin
ujpadmin4115 4063 0 00:42 pts/0 00:00:00 grep --color=auto power_monitor.sh
ujpadmin@okachimachi:~$
あとは,ACアダプタを取り外したり,バッテリ駆動させることでメールが配信されるか確認する.
Surface UEFIの設定
- UEFIで設定しておくことで,電源が復帰したら自動的にOSが起動してくる設定がある.
Automatic power-on after power loss

