VPSサーバーで「failed to subclass open: failed to open /dev/sr0: Operation not permitted」のエラー
KAGOYAのVPSサーバーで下記のエラーが発生しました。
$ tail /var/log/messages failed to add device /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sr0: failed to subclass open: failed to open /dev/sr0: Operation not permitted
エラーの原因
このエラーは、システムがCD/DVDドライブ(/dev/sr0)へのアクセスを試みたものの、メディアが挿入されていないか、権限・ハードウェアの制限によって読み込みがブロックされた場合に発生する場合が多いです
VPSサーバー・クラウド環境でのこのエラーは、システム(特にファームウェア更新ツールの fwupd)が、仮想的なCD/DVDドライブ(/dev/sr0)の情報を読み取ろうとしたものの、VPS・クラウドでのセキュリティ制限や権限不足によって拒否されたことが原因です。
VPS・クラウドには物理的な光学ドライブが存在しないか、OSインストール用のISOイメージが空の状態でマウントされているため、このエラーが発生します。
エラーの対策
VPS・クラウドには物理的な光学ドライブが存在しないか、OSインストール用のISOイメージが空の状態でマウントされているため、このエラーが発生します。
サーバーの動作自体に実害はない(無視しても問題ない)エラーですが、ログをきれいにしたい場合やエラーを止めたい場合は、以下の対処を行ってください。
管理パネルでISOをデタッチする
管理コントロールパネルにログインして、OSインストール時に使用した「ISOイメージ」が挿入されたままになっていないか確認します。
メディアが挿入したままなら、ISOイメージの「取り出し」または「デタッチ(未設定にする)」を実行します。
原因となっている「fwupd」 サービスを停止・無効化する
エラーを発生させている主な原因は、Linuxのファームウェアを自動更新するバックグラウンドサービス fwupd (Firmware Update Daemon) です。VPS・クラウドなどの仮想環境では、物理ハードウェアのファームウェア更新が必要ないため、このサービスを停止しても問題ありません
fwupdの自動起動を停止するため、以下のコマンドを実行しましたが、static で起動しているので、systemctl disable fwupd では停止できませんでした
$ sudo systemctl disable fwupd 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. $ sudo systemctl is-enabled fwupd static
static 状態のサービスは disable コマンドで無効化できまないので、mask コマンドを使用することで強制的に起動を阻止(無効化)できます。
また、fwupd は、定期的にアップデートをチェックするタイマー(fwupd-refresh.timer)によって呼び出されている可能性が高いです。こちらも合わせて停止・無効化します。
# サービスを停止する $ sudo systemctl stop fwupd # サービスをマスクして起動できなくする $ sudo systemctl mask fwupd Created symlink '/etc/systemd/system/fwupd.service' → '/dev/null'. # タイマーの停止と無効化 $ sudo systemctl stop fwupd-refresh.timer $ sudo systemctl disable fwupd-refresh.timer Removed '/etc/systemd/system/timers.target.wants/fwupd-refresh.timer'.

