0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntuで/var/log/auth.logが200GBに肥大化した原因と対処法

0
Posted at

Ubuntu 22.04 環境でディスク容量が異常に増加していたため調査したところ、/var/log/auth.logが200GB以上に膨れ上がっていました。
原因は suspend.target に関するエラーが秒単位で記録され続けていたこと。
その対応記録と再発防止策をまとめます。

環境

  • OS:Ubuntu 22.04
  • 状況:ディスク使用量が異常に増加
  • 原因:/var/log/auth.log が肥大化(約200GB)

原因調査

auth.log を確認すると、以下のようなログが秒単位で大量に記録されていました:

Unit suspend.target is masked, refusing operation.
Failed to execute suspend operation: Permission denied

このログが延々と繰り返されており、ログファイルが肥大化していました。

suspend.target の状態確認

systemctl status suspend.target

結果:

○ suspend.target
     Loaded: masked (Reason: Unit suspend.target is masked.)
     Active: inactive (dead)

この状態でサスペンドが試行され続け、ログにエラーが記録されていたようです。

対応内容

  1. サスペンド関連の systemd ユニットを無効化
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
  1. logind.conf の設定変更
sudo nano /etc/systemd/logind.conf

以下のようにsuspend イベントを無視する設定に変更:

HandleLidSwitch=ignore
HandleLidSwitchDocked=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
IdleAction=ignore
  1. 設定反映
sudo systemctl restart systemd-logind

→ これで suspend.target のエラーが止まり、auth.log の肥大化も収まりました。

ログの整理

auth.log を空にする(ファイルは残す)

sudo truncate -s 0 /var/log/auth.log

journalログを 500MB に制限

sudo journalctl --vacuum-size=500M

まとめ

  • suspend.target の masked 状態でサスペンドが試行されると、auth.log に大量のエラーが記録される
  • logind.conf で lid/suspend イベントを無視することで回避可能
  • ログ肥大化はディスク圧迫の原因になるため、定期的な確認と設定の見直しが重要
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?