Debian 11大版本升级记录

发布于 2023-06-12  815 次阅读


听说Debian 12正式版发布了,就打算来体验一下新版本。

刚好有一台测试用虚拟机用的是Debian 11,就拿它升级一下看看。

1.准备工作

升级之前,按照惯例先得备份。

测试环境嘛,做个静默快照就当作是备份了。

2.升级过程

2.1.更新Debian 11系统

用root账户登录到Debian 11系统中,先开个screen窗口。

screen -S upgrade

然后执行以下命令将Debian 11系统当前的软件包及补丁更新到最新。

apt update && sudo apt upgrade -y

2.2.修改apt源

更新完成后,先将当前的sources.list文件备份一下。

cp /etc/apt/sources.list /etc/apt/sources.list.bullseye.bak

然后找个自己常用的镜像站或者使用Debian官方源,将sources.list中的Debian 11软件源替换成Debian 12源。我这里用的是TUNA的镜像。

cat > /etc/apt/sources.list << EOF
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF

2.3.更新大版本

换完源就可以进行大版本更新了。

apt update && apt full-upgrade -y

更新过程中可能会提示是否自动重启因运行库升级导致中断的相关服务,这里选择的是“Yes”。如果选“No”的话待会儿就会一个个地手动确认重启。

如果新版本软件的配置文件有所更新,会要求选择如何处理新版本配置文件。我不想重新再改配置,因此就选择了“keep the local version currently installed”,保持现有的配置文件不变。

2.4.重启系统

更新完成后,建议重启一下操作系统,重启后系统将以Debian 12默认的Linux 6.1内核启动。

reboot

2.5.验证版本

重启后进入系统,执行以下命令看看当前运行的Debian版本。不出意外的话,显示的版本是12 (bookworm)。

cat /etc/os-release

2.6.文件清理

更新完成后,可以选择清理掉老版本的软件包以及用不到的依赖。

apt autoclean && apt autoremove

3.个人吐槽

更新完成,来看看里面运行的服务正不正常。

这个测试虚拟机里主要运行的是bind9 DNS服务端。敲了一下systemctl status bind9,发现服务启动失败。

于是用named-checkconf命令检查配置文件,提示说“option 'dnssec-enable' no longer exists”。

查了查官方文档,Debian 12用的9.18版本的bind已经弃用了dnssec-enable选项,强制启用dnssec功能。

将那一行注释掉后重启服务,就可以正常运行了。

看来新版本的配置文件还是得研究一下的,万一弃用或者修改了哪个选项导致旧版本配置文件报错,相关服务就没法运行了。