UJP - 技術情報1

Life is fun and easy!

不正IP報告数

Okan Sensor
 
メイン
ログイン
ブログ カテゴリ一覧

Surface Go 2 on Ubuntu Serverで不要なサービスを停止する

Surface Go 2 on Ubuntu Serverで不要なサービスを停止する


更新履歴

  • 2026/05/17 初版
  • 2026/05/17 FirefoxのAppArmor解除方法の追記

目次

はじめに

 Surface Go 2にUbuntu ServerをインストールしてFirefoxをkioskモードで起動してサイネージにしているが,電気代が高いので,OSで動作している不要なサービスを停止してみる.
 なお,Snapdを停止したので,snap経由でインストールしたFirefoxが動作しなくなった.snapでremoveしてaptでインストール したが,その際にAppArmorでブロックされた情報が残っていてFirefoxが起動しないので,AppArmorの登録解除もおこなった.

動作しているサービスの一覧

  • 最初に,現在動作しているサービスの一覧を確認.
  • セットアップ状態によって動作してているものは違うと思いので,まずは現状確認.
ujpadmin@okachimachi:~$ systemctl list-units --type=service --state=running🆑
  UNIT                        LOAD   ACTIVE SUB     DESCRIPTION
  accounts-daemon.service     loaded active running Accounts Service
  avahi-daemon.service        loaded active running Avahi mDNS/DNS-SD Stack
  cron.service                loaded active running Regular background program processing daemon
  dbus.service                loaded active running D-Bus System Message Bus
  iio-sensor-proxy.service    loaded active running IIO Sensor Proxy service
  ModemManager.service        loaded active running Modem Manager
  multipathd.service          loaded active running Device-Mapper Multipath Device Controller
  netplan-wpa-wlp1s0.service  loaded active running WPA supplicant for netplan wlp1s0
  networkd-dispatcher.service loaded active running Dispatcher daemon for systemd-networkd
  NetworkManager.service      loaded active running Network Manager
  polkit.service              loaded active running Authorization Manager
  postfix@-.service           loaded active running Postfix Mail Transport Agent (instance -)
  rsyslog.service             loaded active running System Logging Service
  sddm.service                loaded active running Simple Desktop Display Manager
  snapd.service               loaded active running Snap Daemon
  ssh.service                 loaded active running OpenBSD Secure Shell server
  switcheroo-control.service  loaded active running Switcheroo Control Proxy service
  systemd-journald.service    loaded active running Journal Service
  systemd-logind.service      loaded active running User Login Management
  systemd-networkd.service    loaded active running Network Configuration
  systemd-resolved.service    loaded active running Network Name Resolution
  systemd-timesyncd.service   loaded active running Network Time Synchronization
  systemd-udevd.service       loaded active running Rule-based Manager for Device Events and Files
  thermald.service            loaded active running Thermal Daemon Service
  udisks2.service             loaded active running Disk Manager
  unattended-upgrades.service loaded active running Unattended Upgrades Shutdown
  upower.service              loaded active running Daemon for power management
  user@1000.service           loaded active running User Manager for UID 1000
  wpa_supplicant.service      loaded active running WPA supplicant

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

29 loaded units listed.
ujpadmin@okachimachi:~$
  • 起動時にEnabledになっているサービスの一覧.
ujpadmin@okachimachi:~$ systemctl list-unit-files --type=service --state=enabled
UNIT FILE                              STATE   PRESET
accounts-daemon.service                enabled enabled
anacron.service                        enabled enabled
apparmor.service                       enabled enabled
apport.service                         enabled enabled
avahi-daemon.service                   enabled enabled
blk-availability.service               enabled enabled
cloud-config.service                   enabled enabled
cloud-final.service                    enabled enabled
cloud-init-local.service               enabled enabled
cloud-init.service                     enabled enabled
console-setup.service                  enabled enabled
cron.service                           enabled enabled
dmesg.service                          enabled enabled
e2scrub_reap.service                   enabled enabled
finalrd.service                        enabled enabled
getty@.service                         enabled enabled
gpu-manager.service                    enabled enabled
grub-common.service                    enabled enabled
grub-initrd-fallback.service           enabled enabled
keyboard-setup.service                 enabled enabled
lm-sensors.service                     enabled enabled
lvm2-monitor.service                   enabled enabled
ModemManager.service                   enabled enabled
multipathd.service                     enabled enabled
networkd-dispatcher.service            enabled enabled
NetworkManager-dispatcher.service      enabled enabled
NetworkManager-wait-online.service     enabled enabled
NetworkManager.service                 enabled enabled
open-iscsi.service                     enabled enabled
open-vm-tools.service                  enabled enabled
pollinate.service                      enabled enabled
postfix.service                        enabled enabled
rsyslog.service                        enabled enabled
sddm.service                           enabled enabled
secureboot-db.service                  enabled enabled
setvtrgb.service                       enabled enabled
snapd.apparmor.service                 enabled enabled
snapd.autoimport.service               enabled enabled
snapd.core-fixup.service               enabled enabled
snapd.recovery-chooser-trigger.service enabled enabled
snapd.seeded.service                   enabled enabled
snapd.service                          enabled enabled
snapd.system-shutdown.service          enabled enabled
ssl-cert.service                       enabled enabled
switcheroo-control.service             enabled enabled
sysstat.service                        enabled enabled
systemd-networkd-wait-online.service   enabled enabled
systemd-networkd.service               enabled enabled
systemd-pstore.service                 enabled enabled
systemd-resolved.service               enabled enabled
systemd-timesyncd.service              enabled enabled
thermald.service                       enabled enabled
tlp.service                            enabled enabled
ua-reboot-cmds.service                 enabled enabled
ubuntu-advantage.service               enabled enabled
udisks2.service                        enabled enabled
ufw.service                            enabled enabled
unattended-upgrades.service            enabled enabled
vgauth.service                         enabled enabled
wpa_supplicant.service                 enabled enabled

60 unit files listed.
ujpadmin@okachimachi:~$

サービスの必要性の確認

  • 動作しているサービスから,提供機能から,サイネージに必要かどうかを判断する.

停止可能なサービス(サイネージでは不要)

  • 一般的なサイネージ運用において不要で.停止しても画面表示やネットワークに影響を与えない.
サービス名何に使われているか停止していい理由
postfix@-.serviceメール送信プログラムサーバーから外部へメールを飛ばす必要がなければ不要。
ModemManager.service4G/5Gなどのモバイルデータ通信管理端末にSIMカードを挿して通信していない(有線LANやWi-Fi)なら不要。
multipathd.serviceストレージの多重経路(冗長化)制御特殊なサーバー用外付けストレージを使っていない限り不要。
iio-sensor-proxy.service画面の自動回転や照度センサーの制御タブレットのように端末自体を傾けて画面を回転させないなら不要。
switcheroo-control.service2つのGPU(内蔵と外付け)の切り替え制御グラフィックボードを2枚挿して使い分けるような構成でなければ不要。

  • うちの場合,電源監視でメール通知を使っているから,メールサーバは必要.
  • モバイルデータ通信は行ってない.
  • ストレージも内蔵以外は使ってない.
  • 画面回転・傾き検出(つまりジャイロセンサー),照度調整は使ってない.
  • GPU切り替えもしてない..

条件付きで停止可能なサービス(運用の方法による)

  • 環境や運用ルール止めても良いサービスの候補.
サービス名何に使われているか停止できる条件
avahi-daemon.service「ubuntu.local」などの名前で接続する機能端末をIPアドレスで直接管理しており、Macや他機器からの自動検出が不要なら停止可能。
ssh.service遠隔操作(SSH)用のサーバー完全に現地(ディスプレイの前)でしかメンテナンスせず、リモート操作しないなら停止可能。
snapd.serviceSnap形式のアプリ管理・自動更新表示用のブラウザやプレイヤーをSnap(Ubuntu標準のストア)でインストールしていなければ停止可能。
unattended-upgrades.serviceOSのセキュリティ自動アップデート運用中に勝手に更新・再起動されると困るため、手動アップデートに変えるなら停止推奨。
thermald.serviceIntel製CPUの過熱防止・温度管理適切なファン冷却がされており、過度な負荷がかからないサイネージなら停止しても大きな問題になりにくい。
  • sshはリモートメンテナンスで停止負荷.
  • OSもFirefoxもアップデートはさせないので停止可能.
  • ファンコントロール,Surface Go 2はファンを搭載してないので不要かと思いきや,ファンがないのでCPU処理能力を落として対応(サーマルスロットリング)するので必須となる.

必須のサービス(停止不可)

  • サイネージの画面表示,ネットワーク通信,およびOSの基本動作に直結しているので絶対に停止できないサービス
  • 画面表示に必須
    • sddm.service (ディスプレイマネージャー:画面を表示し、自動ログイン等を行う基礎)
    • user@1000.service (サインインしているユーザーの環境を維持する)
  • ネットワーク維持に必須(有線・Wi-Fi共通)
    •  NetworkManager.service / systemd-networkd.service (通信の制御)
    • netplan-wpa-wlp1s0.service / wpa_supplicant.service (Wi-Fi接続の維持)
    • systemd-resolved.service (Webサイトや配信サーバーのURLをIPアドレスに変換する)
    • systemd-timesyncd.service (時計を正確に合わせる:サイネージの時間指定再生に必須)
  • OSの根幹システム(停止すると起動しなくなる)
    • dbus.service / polkit.service / accounts-daemon.service / systemd-logind.service
    • systemd-journald.service / systemd-udevd.service / rsyslog.service / cron.service
    • udisks2.service / networkd-dispatcher.service

不要なサービスを停止する

停止可能なサービス(サイネージでは不要)

  • ModemManager.service(4G/5Gなどのモバイルデータ通信管理 )を停止.
ujpadmin@okachimachi:~$ sudo systemctl disable --now ModemManager.service🆑
[sudo] password for server:🔑
Removed "/etc/systemd/system/dbus-org.freedesktop.ModemManager1.service".
Removed "/etc/systemd/system/multi-user.target.wants/ModemManager.service".
ujpadmin@okachimachi:~$
  • multipathd.service(ストレージの多重経路 冗長化制御)の停止.
ujpadmin@okachimachi:~$ sudo systemctl disable --now multipathd.service🆑
Removed "/etc/systemd/system/sockets.target.wants/multipathd.socket".
Removed "/etc/systemd/system/sysinit.target.wants/multipathd.service".
Disabling 'multipathd.service', but its triggering units are still active:
multipathd.socket
Stopping 'multipathd.service', but its triggering units are still active:
multipathd.socket
ujpadmin@okachimachi:~$
  • multipathd.service を停止しようとした際に出たこのメッセージは「サービス本体(service)は止めたが,それを呼び出す呼びソケットがまだ稼働中という警告.
  • ソケット側も停止して,本体とソケットをマスクして2度と起動しない様にして,確認する.
ujpadmin@okachimachi:~$ sudo systemctl disable --now multipathd.socket🆑
ujpadmin@okachimachi:~$ sudo systemctl mask multipathd.service multipathd.socket🆑
Created symlink /etc/systemd/system/multipathd.service → /dev/null.
Created symlink /etc/systemd/system/multipathd.socket → /dev/null.
ujpadmin@okachimachi:~$ systemctl status multipathd.service multipathd.socket🆑
○ multipathd.service
     Loaded: masked (Reason: Unit multipathd.service is masked.)
     Active: inactive (dead)

May 17 16:37:21 okachimachi systemd[1]: Starting multipathd.service - Device-Mapper Multipath Device Controller...
May 17 16:37:22 okachimachi multipathd[398]: multipathd v0.9.4: start up
May 17 16:37:22 okachimachi multipathd[398]: reconfigure: setting up paths and maps
May 17 16:37:21 okachimachi systemd[1]: Started multipathd.service - Device-Mapper Multipath Device Controller.
May 17 17:56:11 okachimachi multipathd[398]: multipathd: shut down
May 17 17:56:11 okachimachi systemd[1]: Stopping multipathd.service - Device-Mapper Multipath Device Controller...
May 17 17:56:11 okachimachi systemd[1]: multipathd.service: Deactivated successfully.
May 17 17:56:11 okachimachi systemd[1]: Stopped multipathd.service - Device-Mapper Multipath Device Controller.

○ multipathd.socket
     Loaded: masked (Reason: Unit multipathd.socket is masked.)🈁
     Active: inactive (dead)🈁

May 17 18:01:39 okachimachi systemd[1]: multipathd.socket: Deactivated successfully.
May 17 18:01:39 okachimachi systemd[1]: Closed multipathd.socket - multipathd control socket.
 3 ujpadmin@okachimachi:~$
  • maskされてinactiveになっている.
  • iio-sensor-proxy.service    画面の自動回転や照度センサーの制御を停止する
$ sudo systemctl disable --now iio-sensor-proxy.service🆑
The unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,
Also=, or Alias= settings in the [Install] section, and DefaultInstance= for
template units). This means they are not meant to be enabled or disabled using systemctl.

Possible reasons for having these kinds of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/, .requires/, or .upholds/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.
ujpadmin@okachimachi:~$
  • 「このサービスはOS起動時に自動実行される設定(Install設定)が最初からないため、disable コマンドを受け付けません」というLinuxの仕様による通知.
  • このサービスはdisable が効かない代わりにmask(マスク)コマンドを使うことで完全に停止・無効化する.
ujpadmin@okachimachi:~$ sudo systemctl stop iio-sensor-proxy.service🆑
ujpadmin@okachimachi:~$ sudo systemctl mask iio-sensor-proxy.service🆑
Created symlink /etc/systemd/system/iio-sensor-proxy.service → /dev/null.
ujpadmin@okachimachi:~$
  • switcheroo-control.service 2つのGPU(内蔵と外付け)の切り替え制御を停止する.
ujpadmin@okachimachi:~$ sudo systemctl disable --now switcheroo-control.service🆑
Removed "/etc/systemd/system/graphical.target.wants/switcheroo-control.service".
ujpadmin@okachimachi:~$

条件付きで停止可能なサービス(運用の方法による)

ujpadmin@okachimachi:~$ sudo systemctl disable --now avahi-daemon.service🆑
Removed "/etc/systemd/system/dbus-org.freedesktop.Avahi.service".
Removed "/etc/systemd/system/sockets.target.wants/avahi-daemon.socket".
Removed "/etc/systemd/system/multi-user.target.wants/avahi-daemon.service".
Disabling 'avahi-daemon.service', but its triggering units are still active:
avahi-daemon.socket
Stopping 'avahi-daemon.service', but its triggering units are still active:
avahi-daemon.socket
ujpadmin@okachimachi:~$
  • これも停止したけどソケットが残っている.
  • 停止してマスクする.
ujpadmin@okachimachi:~$ sudo systemctl disable --now avahi-daemon.socket🆑
ujpadmin@okachimachi:~$ sudo systemctl mask avahi-daemon.service avahi-daemon.socket🆑
Created symlink /etc/systemd/system/avahi-daemon.service → /dev/null.
Created symlink /etc/systemd/system/avahi-daemon.socket → /dev/null.
ujpadmin@okachimachi:~$
  • snapd.service Snap形式のアプリ管理・自動更新を停止する
ujpadmin@okachimachi:~$ sudo systemctl disable --now snapd.service🆑
Removed "/etc/systemd/system/multi-user.target.wants/snapd.service".
Disabling 'snapd.service', but its triggering units are still active:
snapd.socket
Stopping 'snapd.service', but its triggering units are still active:
snapd.socket
ujpadmin@okachimachi:~$
  • これも停止したけどソケットが残っている.
  • 停止してマスクする.
ujpadmin@okachimachi:~$ sudo systemctl disable --now snapd.socket🆑
Removed "/etc/systemd/system/sockets.target.wants/snapd.socket".
ujpadmin@okachimachi:~$ sudo systemctl mask snapd.service snapd.socket snapd.seeded.service🆑
Created symlink /etc/systemd/system/snapd.service → /dev/null.
Created symlink /etc/systemd/system/snapd.socket → /dev/null.
Created symlink /etc/systemd/system/snapd.seeded.service → /dev/null.
ujpadmin@okachimachi:~$
  • unattended-upgrades.service    OSのセキュリティ自動アップデートを停止する.
ujpadmin@okachimachi:~$ sudo systemctl disable --now unattended-upgrades.service🆑
Synchronizing state of unattended-upgrades.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install disable unattended-upgrades
Removed "/etc/systemd/system/multi-user.target.wants/unattended-upgrades.service".
ujpadmin@okachimachi:~$

作業後のサービスリスト

  • 停止をおこなった後,現在のサービスの稼働状態.
 ujpadmin@okachimachi:~$ systemctl list-units --type=service --state=running🆑
  UNIT                        LOAD   ACTIVE SUB     DESCRIPTION
  accounts-daemon.service     loaded active running Accounts Service
  cron.service                loaded active running Regular background program processing daemon
  dbus.service                loaded active running D-Bus System Message Bus
  fwupd.service               loaded active running Firmware update daemon
  netplan-wpa-wlp1s0.service  loaded active running WPA supplicant for netplan wlp1s0
  networkd-dispatcher.service loaded active running Dispatcher daemon for systemd-networkd
  NetworkManager.service      loaded active running Network Manager
  polkit.service              loaded active running Authorization Manager
  postfix@-.service           loaded active running Postfix Mail Transport Agent (instance -)
  rsyslog.service             loaded active running System Logging Service
  sddm.service                loaded active running Simple Desktop Display Manager
  ssh.service                 loaded active running OpenBSD Secure Shell server
  systemd-journald.service    loaded active running Journal Service
  systemd-logind.service      loaded active running User Login Management
  systemd-networkd.service    loaded active running Network Configuration
  systemd-resolved.service    loaded active running Network Name Resolution
  systemd-timesyncd.service   loaded active running Network Time Synchronization
  systemd-udevd.service       loaded active running Rule-based Manager for Device Events and Files
  thermald.service            loaded active running Thermal Daemon Service
  udisks2.service             loaded active running Disk Manager
  upower.service              loaded active running Daemon for power management
  user@1000.service           loaded active running User Manager for UID 1000
  wpa_supplicant.service      loaded active running WPA supplicant

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

23 loaded units listed.
ujpadmin@okachimachi:~$

追加でサービスを止める Firmware Update

  • fwupd.serviceは,Firmware update daemonですが,2つの理由でこのサービスは,現在は不要.
    • MicrosoftはLinux経由でのファームウェア更新サービスを提供していない.
    • Surface Go 2のファームウェアやドライバのサポートサービスは2024年12月30日をもって終了.
  • ということで,停止する.
$ sudo systemctl disable --now fwupd.service🆑
The unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,
Also=, or Alias= settings in the [Install] section, and DefaultInstance= for
template units). This means they are not meant to be enabled or disabled using systemctl.

Possible reasons for having these kinds of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/, .requires/, or .upholds/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.
  • このサービスはOS起動時に自動実行される設定(Install設定)が最初からないため、disable コマンドを受け付けない.
  • D-Busや他のイベントに連携して動き出すので,マスクして起動しない様にする.
ujpadmin@okachimachi:~$ sudo systemctl stop fwupd.service🆑
ujpadmin@okachimachi:~$ sudo systemctl mask fwupd.service🆑
Created symlink /etc/systemd/system/fwupd.service → /dev/null.
ujpadmin@okachimachi:~$

設定が有効になって定着したか,OSを再起動して確かめる

  • reboot.
ujpadmin@okachimachi:~$ sudo reboot🆑

Broadcast message from root@okachimachi on pts/1 (Sun 2026-05-17 18:35:28 JST):

The system will reboot now!

ujpadmin@okachimachi:~$
  • 再起動後,ログインしてサービスの状態を確認.
ujpadmin@okachimachi:~$ systemctl list-units --type=service --state=running🆑
  UNIT                        LOAD   ACTIVE SUB     DESCRIPTION
  accounts-daemon.service     loaded active running Accounts Service
  cron.service                loaded active running Regular background program processing daemon
  dbus.service                loaded active running D-Bus System Message Bus
  netplan-wpa-wlp1s0.service  loaded active running WPA supplicant for netplan wlp1s0
  networkd-dispatcher.service loaded active running Dispatcher daemon for systemd-networkd
  NetworkManager.service      loaded active running Network Manager
  polkit.service              loaded active running Authorization Manager
  postfix@-.service           loaded active running Postfix Mail Transport Agent (instance -)
  rsyslog.service             loaded active running System Logging Service
  sddm.service                loaded active running Simple Desktop Display Manager
  ssh.service                 loaded active running OpenBSD Secure Shell server
  systemd-journald.service    loaded active running Journal Service
  systemd-logind.service      loaded active running User Login Management
  systemd-networkd.service    loaded active running Network Configuration
  systemd-resolved.service    loaded active running Network Name Resolution
  systemd-timesyncd.service   loaded active running Network Time Synchronization
  systemd-udevd.service       loaded active running Rule-based Manager for Device Events and Files
  thermald.service            loaded active running Thermal Daemon Service
  udisks2.service             loaded active running Disk Manager
  upower.service              loaded active running Daemon for power management
  user@1000.service           loaded active running User Manager for UID 1000
  wpa_supplicant.service      loaded active running WPA supplicant

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

22 loaded units listed.
ujpadmin@okachimachi:~$
  • 停止したものが止まり,必要なものが動作していることを確認する.

Firefoxが起動しなくなったのでsnapからaptに切り替えてインストールする

  • OSを再起動しても,Firefoxが自動起動しなくなった.
  • アプリケーションメニューからタップしても起動しない.
  • これはUbuntuの標準ストアのSnapのサービスsnapdを停止した影響と思われる.
  • まずはコマンドでfirefoxを起動して確認.
ujpadmin@okachimachi:~$ DISPLAY=:0 firefox🆑
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/local/share/doc /usr/local/share/doc none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/local/share/doc" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/cups/doc-root /usr/share/cups/doc-root none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/cups/doc-root" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gimp/2.0/help /usr/share/gimp/2.0/help none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/gimp/2.0/help" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/gtk-doc /usr/share/gtk-doc none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/gtk-doc" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/libreoffice/help /usr/share/libreoffice/help none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/libreoffice/help" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/sphinx_rtd_theme /usr/share/sphinx_rtd_theme none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/sphinx_rtd_theme" because it would affect the host in "/var/lib/snapd"
update.go:85: cannot change mount namespace according to change mount (/var/lib/snapd/hostfs/usr/share/xubuntu-docs /usr/share/xubuntu-docs none bind,ro 0 0): cannot write to "/var/lib/snapd/hostfs/usr/share/xubuntu-docs" because it would affect the host in "/var/lib/snapd"
error: cannot communicate with server: Post "http://localhost/v2/snapctl": dial unix /run/snapd-snap.socket: connect: no such file or directory
ERROR: not connected to the gnome-46-2404 content interface.
ujpadmin@okachimachi:~$
  • snapdのサービスを停止したので,起動できない.
  • サイネージ運用では,Snap版のFirefoxは「裏で勝手に自動更新が走り,その間サイネージが真っ暗になる」「起動が遅い」といったトラブルが多いため通常のプログラム(apt版)に入れ替えるのがベスト...とのこと.
  • Snap版でインストールしているので,アンインストールする.
ujpadmin@okachimachi:~$ sudo snap remove firefox🆑
error: cannot communicate with server: Post "http://localhost/v2/snaps/firefox": dial unix /run/snapd.socket: connect: no such file or directory
ujpadmin@okachimachi:~$
  • Snapdを停止しているのでアンインストールできない.
  • マスクを解除して,サービスを起動する.
ujpadmin@okachimachi:~$ sudo systemctl unmask snapd.service snapd.socket🆑
Removed "/etc/systemd/system/snapd.service".
Removed "/etc/systemd/system/snapd.socket".
ujpadmin@okachimachi:~$ sudo systemctl start snapd.service snapd.socket🆑
ujpadmin@okachimachi:~$
  • firefoxを削除.
ujpadmin@okachimachi:~$ sudo snap remove firefox🆑
firefox removed (snap data snapshot saved)
ujpadmin@okachimachi:~$
  • 削除できたので,Snapdを停止する.(マスクもする)
ujpadmin@okachimachi:~$ sudo systemctl disable --now snapd.service snapd.socket🆑
Disabling 'snapd.service', but its triggering units are still active:
snapd.socket
ujpadmin@okachimachi:~$ sudo systemctl mask snapd.service snapd.socket🆑
Created symlink /etc/systemd/system/snapd.service → /dev/null.
Created symlink /etc/systemd/system/snapd.socket → /dev/null.
ujpadmin@okachimachi:~$
  • firefoxをインストールするために,MozillaTeamのリポジトリを追加.
ujpadmin@okachimachi:~$ sudo add-apt-repository ppa:mozillateam/ppa🆑
PPA publishes dbgsym, you may need to include 'main/debug' component
Repository: 'Types: deb
URIs: https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu/
Suites: noble
Components: main
'
Description:
Mozilla Team's Firefox stable + 140 ESR and Thunderbird 140 ESR builds

Support for Ubuntu 20.04 and later
More info: https://launchpad.net/~mozillateam/+archive/ubuntu/ppa
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.🆑
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease
Get:3 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [21.9 kB]
Get:4 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [74.2 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:6 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu noble InRelease [24.4 kB] 🈁
Hit:7 https://pkg.surfacelinux.com/debian release InRelease
Get:8 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:9 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu noble/main amd64 Packages [34.1 kB]
Get:10 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [177 kB]
Get:11 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [386 kB]
Get:12 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B]
Get:13 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [5,796 B]
Get:14 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [10.5 kB]
Get:15 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu noble/main Translation-en [7,144 B]
Fetched 1,121 kB in 2s (501 kB/s)
Reading package lists... Done
ujpadmin@okachimachi:~$
  • リポジトリが追加された.
  • 通常のPPAを最優先にする設定を入れる
ujpadmin@okachimachi:~$ echo '
Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
' | sudo tee /etc/apt/preferences.d/mozillateam-ppa🆑

Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
  • パッケージ情報をアップデートする.
ujpadmin@okachimachi:~$ sudo apt update🆑
Hit:1 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Hit:5 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu noble InRelease
Hit:6 https://pkg.surfacelinux.com/debian release InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
48 packages can be upgraded. Run 'apt list --upgradable' to see them.
ujpadmin@okachimachi:~$
  • Firefoxをインストールする.
ujpadmin@okachimachi:~$ sudo apt install -y firefox🆑
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:

ー略ー

The following packages will be DOWNGRADED:
  firefox
0 upgraded, 3 newly installed, 1 downgraded, 0 to remove and 48 not upgraded.
E: Packages were downgraded and -y was used without --allow-downgrades.🈁
ujpadmin@okachimachi:~$
  • 古いバージョン(Mozilla公式の通常版)へのダウングレードが含まれているため、安全のためにインストールを中断しました」という警告.
  • Ubuntuの仕組み上、中身がSnapだった既存のダミーパッケージから、新しく追加したMozilla公式の軽量な通常版(PPA版)へ切り替える際に、システム側はこれを「ダウングレード」とみなす.
  • ダウングレードを許可するオプションを付けて再度実行する.
ujpadmin@okachimachi:~$ sudo apt install -y --allow-downgrades firefox🆑
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:

ー略ー
  • インストールできたら,バージョンを確認.
ujpadmin@okachimachi:~$ DISPLAY=:0 firefox --version🆑
[15023] Sandbox: CanCreateUserNamespace() unshare(CLONE_NEWPID): EPERM
Mozilla Firefox 150.0.3
ujpadmin@okachimachi:~$
  • 本日時点での最新になってる.バージョン150なのか.
  • OSを再起動する.
ujpadmin@okachimachi:~$ sudo reboot🆑

Broadcast message from root@okachimachi on pts/1 (Sun 2026-05-17 19:40:17 JST):

The system will reboot now!

ujpadmin@okachimachi:~$ Connection to 192.168.20.61 closed by remote host.
Connection to 192.168.20.61 closed.
$
  • ....自動起動してこない.
  • アプリケーションメニューで起動すると,次の様なダイアログが出る.

firefox is already running,but is not responding. To use firefox ,you must first close the existing forefox process,restart your device,or use a different profile.
  • メッセージが出る原因はSnap版のFirefoxをアンインストール時に『このプロファイルは現在使用中である』という鍵をかけたまま、ロックファイルが取り残されてしまったことっぽいけれど,Ubuntuのセキュリティ(AppArmor)によるブロックとのこと.
    • Ubuntu(24.04 LTS以降)ではセキュリティが大幅に強化され、「Snap以外の方法(今回導入したPPAなど)で入れたブラウザが、独自のサンドボックス(安全な隔離 領域)を作ること」を、セキュリティ機能(AppArmor)がデフォルトで禁止(EPERM = 権限エラー)する仕様になりました。
ujpadmin@okachimachi:~/snap$ DISPLAY=:0 firefox🆑
[42371] Sandbox: CanCreateUserNamespace() unshare(CLONE_NEWPID): EPERM
^C
ujpadmin@okachimachi:~/snap$
  • AppArmorのプロファイルが残っており,aptのFirefoxを起動するとAppArmorがブロックしてしまう.
    • SnapのFirefoxはサンドボックス内で動作するため,AppArmorのプロファイルもSnap専用の設定になっている.
    • aptのFirefoxはSnapとは異なるパスやnamespace(unshare(CLONE_NEWPID))を使うため,Snap用のプロファイルのルールに引っかかってEPERM(権限エラー)が発生.
  • AppArmorの状態を確認
 ujpadmin@okachimachi:~/snap$ sudo aa-status | grep firefox🆑
   firefox
   firefox//browser_java
   firefox//browser_openjdk
   firefox//lsb_release
   firefox//sanitized_helper
   /usr/lib/firefox/firefox (44913) firefox
   /usr/lib/firefox/firefox (44988) firefox
ujpadmin@okachimachi:~/snap$
  • AppArmorは disable/ フォルダにリンクがあるプロファイルを「無効」として扱うので,/etc/apparmor.d/disable/にシンボリックリンクを作成する.
ujpadmin@okachimachi:~/snap$ sudo ln -s /etc/apparmor.d/usr.lib.firefox.firefox /etc/apparmor.d/disable/🆑
ujpadmin@okachimachi:~/snap$
  • 現在カーネルにロードされているAppArmorのFirefoxプロファイルをメモリから削除して即座に無効化する.
ujpadmin@okachimachi:~/snap$ sudo apparmor_parser -R /etc/apparmor.d/usr.lib.firefox.firefox🆑
File /etc/apparmor.d/usr.lib.firefox.firefox not found, skipping...
ujpadmin@okachimachi:~/snap$
  • メモリにロードされたものはなかった.
  • ファイルを確認する.
ujpadmin@okachimachi:~/snap$ ls /etc/apparmor.d/ | grep firefox🆑
firefox
usr.bin.firefox
ujpadmin@okachimachi:~/snap$
  • 両方のファイルを無効化する.
ujpadmin@okachimachi:~/snap$ sudo apparmor_parser -R /etc/apparmor.d/firefox🆑
ujpadmin@okachimachi:~/snap$ sudo apparmor_parser -R /etc/apparmor.d/usr.bin.firefox🆑
apparmor_parser: Unable to remove "firefox".  Profile doesn't exist
$
  • AppArmorの現在の状態を表示するコマンドaa-statusを使って,firefoxが登録されているか確認.
ujpadmin@okachimachi:~$ sudo aa-status | grep firefox🆑
ujpadmin@okachimachi:~$
  • 何も表示されてないので,登録されたものが削除された.
  • firefoxが起動するか確認.
ujpadmin@okachimachi:~$ DISPLAY=:0 firefox &
ujpadmin@okachimachi:~$
  • 起動したら成功.
  • AppArmorがFirefoxをブロックしていたのが原因.
  • OS再起動後もAppArmorでFirefoxを無効にする.
ujpadmin@okachimachi:~/snap$ sudo mkdir -p /etc/apparmor.d/disable🆑
ujpadmin@okachimachi:~/snap$ sudo ln -s /etc/apparmor.d/firefox /etc/apparmor.d/disable/firefox🆑
ujpadmin@okachimachi:~/snap$ ls -la /etc/apparmor.d/disable🆑
total 8
drwxr-xr-x 2 root root 4096 May 17 22:51 .
drwxr-xr-x 9 root root 4096 May 17 22:39 ..
lrwxrwxrwx 1 root root   23 May 17 22:51 firefox -> /etc/apparmor.d/firefox → 実際に存在するファイル(今回効いたもの)
lrwxrwxrwx 1 root root   31 May 17 22:39 usr.bin.firefox -> /etc/apparmor.d/usr.bin.firefox → 実際に存在するファイル
lrwxrwxrwx 1 root root   39 May 17 22:47 usr.lib.firefox.firefox -> /etc/apparmor.d/usr.lib.firefox.firefox → 存在せず不要
ujpadmin@okachimachi:~/snap$
  • 不要なリンクは削除.
ujpadmin@okachimachi:~$ sudo rm /etc/apparmor.d/disable/usr.lib.firefox.firefox🆑
ujpadmin@okachimachi:~$
  • これで再起動してもAppArmorからブロック除外される.

広告スペース
Google