How to upgrade Debian11(bullseye) to Debian12(bookworm)

Debian

How to upgrade Debian11(bluesy) to Debian12(bookworm)

ターミナルからコマンドを打ち込んで、debian11(bluesy)からdebian12(bookworm)へのアップグレード作業手順を記事にしました。
各々の環境で、実行した結果に書き換えて読み進めていただければと思います。

現在のバージョンを確認
$ uname -a ; lsb_release -a
Linux host05 5.10.0-23-amd64 #1 SMP Debian 5.10.179-1 (2023-05-12) x86_64 GNU/Linux
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye
残っている設定ファイルを取り除く
残っている設定ファイル表示
$ sudo find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'
/etc/php/8.1/apache2/php.ini.ucf-old
/etc/php/8.1/apache2/php.ini.ucf-dist
残っている設定ファイル削除
$ sudo rm /etc/php/8.1/apache2/php.ini.ucf-old
$ sudo rm /etc/php/8.1/apache2/php.ini.ucf-dist
non-free コンポーネントと non-free-firmware コンポーネント設定

 /etc/apt/sources.list へ deb https://deb.debian.org/debian bookworm main non-free-firmware を追加します。

/etc/apt/sources.list の編集
$ sudo nano /etc/apt/sources.list
# 以下1行追加
deb https://deb.debian.org/debian bookworm main non-free-firmware
gpgv インストール

gpgv がインストールされていない場合はインストールします。
gpgv バージョン 2以降が必要

$ sudo apt -y install gpgv
パッケージの状態チェック

パッケージの hold 状態解除

$ sudo apt-mark showhold
 APT source-list ファイルの準備

source-list ファイル (/etc/apt/sources.list および /etc/apt/sources.list.d/以下のファイル) 中、bullseyeをbookwormへ修正します。

$ sudo nano /etc/apt/sources.list
# bullseye の部分を bookworm へ修正します。
#
# 修正前
deb http://debian-mirror.sakura.ne.jp/debian/ bullseye main
deb-src http://debian-mirror.sakura.ne.jp/debian/ bullseye main
#
deb http://security.debian.org/debian-security bullseye-security main
deb-src http://security.debian.org/debian-security bullseye-security main
#
# 修正後
deb http://debian-mirror.sakura.ne.jp/debian/ bookworm main
deb-src http://debian-mirror.sakura.ne.jp/debian/ bookworm main
#
deb http://security.debian.org/debian-security bookworm-security main
deb-src http://security.debian.org/debian-security bookworm-security main
$ sudo nano /etc/apt/sources.list.d/sury-php.list
# bullseye の部分を bookworm へ修正します。
#
# 修正前
deb https://packages.sury.org/php/ bullseye main
#
# 修正後
deb https://packages.sury.org/php/ bookworm main
$ sudo nano /etc/apt/sources.list.d/gitlab_gitlab-ce.list 
# bullseye の部分を bookworm へ修正します。
#
# 修正前
# this file was generated by packages.gitlab.com for
# the repository at https://packages.gitlab.com/gitlab/gitlab-ce

deb [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main
deb-src [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bullseye main
#
# 修正後
# this file was generated by packages.gitlab.com for
# the repository at https://packages.gitlab.com/gitlab/gitlab-ce

deb [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bookworm main
deb-src [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/debian/ bookworm main
$ sudo nano /etc/apt/sources.list.d/mysql.list
# mysql は bullseye のまま
# 環境によると思いますが、アップグレード完了後に sudo systemctl restart mysql.service で active (running) になりました。(記事作成時点)
セッションの記録開始

アップグレード中のログを記録します。
変更されたパッケージの状態ログ /var/log/apt/history.log
端末の出力ログ /var/log/apt/term.log
アップグレード完了後 exit でログの記録を終了します。

$ sudo script -t 2>~/upgrade-bookwormstep.time -a ~/upgrade-bookwormstep.script
Script started, output log file is '/home/user05/upgrade-bookwormstep.script', timing file is '/dev/stderr'.
パッケージリストの更新
# apt update
システムの最小アップグレード

apt-listchanges パッケージがインストールされていれば、(デフォルト設定で) パッケージのダウンロード後にアップグレードされるパッケージについての重要な情報をページャで表示します。読み終わったら q を押してページャを終了し、アップグレードを続けてください。

# apt -y upgrade --without-new-pkgs
システムのアップグレード

既存の設定ファイルを新しい設定ファイルにするか等、問われます。
特に問題がなければ、既存の設定ファイル選択で良いと思います。

# apt -y full-upgrade
セッションの記録終了

変更されたパッケージの状態ログ /var/log/apt/history.log
端末の出力ログ /var/log/apt/term.log

# exit
不要パッケージ削除
$ sudo apt -y autoremove
$ sudo apt -y autoclean
システム再起動

必要であればシステムを再起動します。

$ sudo reboot
バージョン確認

アップグレード完了後、バージョンを確認します。

$ uname -a ; lsb_release -a
Linux host05 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm
タイトルとURLをコピーしました