概要
- Ubuntu Linux サーバの日々の定常作業として実施するべき apt upgrade 作業手順をまとめる
- 通常のパッケージ更新と Linux カーネルのパッケージ更新の2パターン
セキュリティ更新の情報源
セキュリティ通知サイト (購読用 RSS と Atom もある):
Ubuntu security notices
セキュリティ通知のメーリングリスト
ubuntu-security-announce Info Page
通常のセキュリティアップデート
実施コマンド概要
$ sudo apt update
$ sudo apt upgrade -s
$ sudo apt upgrade
$ sudo checkrestart
apt update
Ubuntu Manpage: apt - コマンドラインインターフェイス
update は、設定されたすべての取得元からパッケージ情報をダウンロードするために使用されます。
apt upgrade
Ubuntu Manpage: apt - コマンドラインインターフェイス
upgrade は、sources.list(5) で設定された取得元からシステムに現在インストール済みのすべてのパッケージで利用可能なアップグレードをインストールするために使用されます。
apt upgrade に -s オプションを付けるとパッケージ更新の予行演習 (シミュレート) ができる。
Ubuntu Manpage: apt-get - APT パッケージ操作ユーティリティ -- コマンドラインインターフェース
-s, --simulate, --just-print, --dry-run, --recon, --no-act
何もしない - 現在のシステム状態に基づいて起こるイベントのシミュレーションを行い、実際にはシステムを変更しません。
checkrestart
checkrestart コマンドは debian-goodies パッケージをインストールすると使えるようになる。
$ sudo apt install debian-goodies
checkrestart コマンドを使うとパッケージの更新に従って再起動する必要があるサービスやプロセスがわかる。
$ sudo checkrestart -a
Found 17 processes using old versions of upgraded files
(11 distinct programs)
(3 distinct packages)
Of these, 1 seem to contain systemd service definitions or init scripts which can be used to restart them.
The following packages seem to have definitions that could be used
to restart their services:
apache2-bin:
4483 /usr/sbin/apache2
15041 /usr/sbin/apache2
15048 /usr/sbin/apache2
15049 /usr/sbin/apache2
These are the initd scripts:
service apache2 restart
These processes (2) do not seem to have an associated init script to restart them:
openjdk-11-jre-headless:amd64:
493 /usr/lib/jvm/java-11-openjdk-amd64/bin/java
897 /usr/lib/jvm/java-11-openjdk-amd64/bin/java
mariadb-server-core-10.3:
691 /usr/sbin/mysqld
Linux カーネルのアップデート
実施コマンド概要
Linux カーネル (linux-image-* パッケージ) は Ubuntu を再起動しないと反映されないので、 reboot や shutdown -r コマンドで再起動する必要がある。
$ sudo apt update
$ sudo apt upgrade -s
$ sudo apt upgrade
$ sudo reboot
カーネル更新例
更新前。パッケージとカーネルのバージョンを確認。
$ dpkg -l | grep linux-image
rc linux-image-5.3.0-26-generic 5.3.0-26.28 amd64 Signed kernel image generic
ii linux-image-5.3.0-29-generic 5.3.0-29.31 amd64 Signed kernel image generic
ii linux-image-5.3.0-40-generic 5.3.0-40.32 amd64 Signed kernel image generic
ii linux-image-5.3.0-42-generic 5.3.0-42.34 amd64 Signed kernel image generic
ii linux-image-generic 5.3.0.42.36 amd64 Generic Linux kernel image
$ uname -mrsv
Linux 5.3.0-42-generic #34-Ubuntu SMP Fri Feb 28 05:49:40 UTC 2020 x86_64
パッケージ更新。
$ sudo apt upgrade
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
アップグレードパッケージを検出しています... 完了
以下のパッケージが新たにインストールされます:
linux-headers-5.3.0-45 linux-headers-5.3.0-45-generic linux-image-5.3.0-45-generic
linux-modules-5.3.0-45-generic linux-modules-extra-5.3.0-45-generic
以下のパッケージはアップグレードされます:
kmod libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libkmod2 linux-firmware linux-generic
linux-headers-generic linux-image-generic linux-libc-dev python3-keyring
アップグレード: 11 個、新規インストール: 5 個、削除: 0 個、保留: 0 個。
OS を再起動。
$ sudo reboot
Linux カーネルが更新される。
$ dpkg -l | grep linux-image
rc linux-image-5.3.0-26-generic 5.3.0-26.28 amd64 Signed kernel image generic
rc linux-image-5.3.0-29-generic 5.3.0-29.31 amd64 Signed kernel image generic
ii linux-image-5.3.0-40-generic 5.3.0-40.32 amd64 Signed kernel image generic
ii linux-image-5.3.0-42-generic 5.3.0-42.34 amd64 Signed kernel image generic
ii linux-image-5.3.0-45-generic 5.3.0-45.37 amd64 Signed kernel image generic
ii linux-image-generic 5.3.0.45.38 amd64 Generic Linux kernel image
$ uname -mrsv
Linux 5.3.0-45-generic #37-Ubuntu SMP Thu Mar 26 20:41:27 UTC 2020 x86_64