Raspbian Stretch (Debian Stretch) でapt-get upgrade後に再起動が必要かどうか調べるには

お知らせ

サイトを引っ越しました。この記事は残しますが、古い内容のものになります。
この記事の最新版は以下のURLで見ることができます。


以下、旧記事となります↓

----------

結論



  • checkrestartまたはneedrestartコマンドで再起動が必要かどうかが分かる
  • 上記コマンドはroot権限が必要
    • sudoをつけて実行
  • needrestartパッケージがインストールされた状態でapt upgradeとすると自動的に再起動の要否が確認できるみたい


結論までのプロセス



以下の2つのパッケージが利用できそう。


比較のため両方インストールして確認してみる。

  • パッケージのインストール
$ sudo apt-get install debian-goodies needrestart
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  dctrl-tools libintl-perl libintl-xs-perl libmodule-find-perl libmodule-scandeps-perl libproc-processtable-perl libsort-naturally-perl libterm-readkey-perl lsof
提案パッケージ:
  debtags popularity-contest xdg-utils zenity needrestart-session | libnotify-bin
以下のパッケージが新たにインストールされます:
  dctrl-tools debian-goodies libintl-perl libintl-xs-perl libmodule-find-perl libmodule-scandeps-perl libproc-processtable-perl libsort-naturally-perl libterm-readkey-perl lsof needrestart
アップグレード: 0 個、新規インストール: 11 個、削除: 0 個、保留: 0 個。
1,454 kB のアーカイブを取得する必要があります。
この操作後に追加で 6,170 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian stretch/main armhf lsof armhf 4.89+dfsg-0.1 [311 kB]

※※(省略)※※

debian-goodies (0.69.1) を設定しています ...
needrestart (2.11-3+deb9u1) を設定しています ...


  • sudo apt update && sudo apt upgrade でパッケージをアップデート
sudo apt update && sudo apt upgrade
取得:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB]                            
取得:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB]                         
取得:3 http://archive.raspberrypi.org/debian stretch/main armhf Packages [221 kB]
取得:4 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB]             
306 kB を 4秒 で取得しました (68.6 kB/s)                              
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています       
状態情報を読み取っています... 完了
アップグレードできるパッケージが 6 個あります。表示するには 'apt list --upgradable' を実行してください。
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
アップグレードパッケージを検出しています... 完了
以下のパッケージはアップグレードされます:
  libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 raspberrypi-bootloader raspberrypi-kernel
アップグレード: 6 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
71.6 MB のアーカイブを取得する必要があります。
この操作後に追加で 5,853 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://archive.raspberrypi.org/debian stretch/main armhf libraspberrypi-doc armhf 1.20190517-1 [31.4 MB]
取得:2 http://archive.raspberrypi.org/debian stretch/main armhf libraspberrypi-dev armhf 1.20190517-1 [404 kB]                                                                                             
取得:3 http://archive.raspberrypi.org/debian stretch/main armhf raspberrypi-kernel armhf 1.20190517-1 [35.1 MB]                                                                                            
取得:4 http://archive.raspberrypi.org/debian stretch/main armhf libraspberrypi-bin armhf 1.20190517-1 [332 kB]                                                                                             
取得:5 http://archive.raspberrypi.org/debian stretch/main armhf libraspberrypi0 armhf 1.20190517-1 [839 kB]                                                                                                
取得:6 http://archive.raspberrypi.org/debian stretch/main armhf raspberrypi-bootloader armhf 1.20190517-1 [3,567 kB]                                                                                       
71.6 MB を 24秒 で取得しました (2,933 kB/s)                                                                                                                                                                
changelog を読んでいます... 完了
(データベースを読み込んでいます ... 現在 49551 個のファイルとディレクトリがインストールされています。)
.../0-libraspberrypi-doc_1.20190517-1_armhf.deb を展開する準備をしています ...
libraspberrypi-doc (1.20190517-1) で (1.20190401-1 に) 上書き展開しています ...
.../1-libraspberrypi-dev_1.20190517-1_armhf.deb を展開する準備をしています ...
libraspberrypi-dev (1.20190517-1) で (1.20190401-1 に) 上書き展開しています ...
.../2-raspberrypi-kernel_1.20190517-1_armhf.deb を展開する準備をしています ...
'rpikernelhack による /boot/bcm2708-rpi-0-w.dtb から /usr/share/rpikernelhack/bcm2708-rpi-0-w.dtb への退避 (divert)' を追加しています
'rpikernelhack による /boot/bcm2708-rpi-b-plus.dtb から /usr/share/rpikernelhack/bcm2708-rpi-b-plus.dtb への退避 (divert)' を追加しています

※※(省略)※※

libraspberrypi0 (1.20190517-1) を設定しています ...
libraspberrypi-doc (1.20190517-1) を設定しています ...
libraspberrypi-dev (1.20190517-1) を設定しています ...
libraspberrypi-bin (1.20190517-1) を設定しています ...
Scanning processes...                                                                                                                                                                                       
Scanning linux images...                                                                                                                                                                                    
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.

  • checkrestart実行
$ sudo checkrestart
Found 1 processes using old versions of upgraded files
(1 distinct program)
(1 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:
udev:
 123 /lib/systemd/systemd-udevd
These are the initd scripts:
service udev restart

  • needrestartを実行すると、ncursesのプロンプトが表示され再起動が必要であることが分かる