VPS如何把Debian 11 升级到Debian 12

Debian 12 是 Debian Linux 发行版的最新版本,于 2023 年 6 月 10 日发布。它带来了最新的软件包、升级和替换一些关键模块。 想要了解Debian 12 的新特性,可以查看 https://linux.cn/article-15901-1.html 。本文将演示从Debian 11 升级到Debian12 的过程。在继续升级之前备份所有数据非常重要,这样,如果升级过程中出现任何问题,您就可以始终恢复到以前的版本。

1.升级所有现有软件包

升级所有现有软件包。使用以下代码升级程序包。

apt update && apt upgrade -y

2.修改包存储库

修改配置文件之前,确认先做好备份

cp -v /etc/apt/sources.list /opt/sources.list-bakup-debian11

现在使用sed命令将包存储库文件中的文本“bullseye”替换为“bookworm”

sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list

现在,您需要更新包以应用更改。

root@vps:~# apt update 
Get:1 http://deb.debian.org/debian bookworm InRelease [147 kB]
Get:2 http://deb.debian.org/debian bookworm-updates InRelease [52.1 kB]
Get:3 http://security.debian.org/debian-security bookworm-security InRelease [48.0 kB]
Get:4 http://deb.debian.org/debian bookworm/main Sources [9,628 kB]
Get:5 http://deb.debian.org/debian bookworm/main amd64 Packages [8,904 kB]

在开始升级之前,让我们使用以下命令验证当前版本,

root@vps:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

3.升级到Debian 12

执行以下命令,由于此过程中涉及的包装数量,这可能需要很长时间才能完成!

apt update -y

一旦您的系统中更新了所有软件包,然后升级您的分发软件包,

apt dist-upgrade -y

输出

Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9) ...
Errors were encountered while processing:
 dbus-daemon
 dbus-user-session
 dbus
 libpam-systemd:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

在此期间,如果任何客户端出现此错误,则要求客户端运行以下3个命令,该错误将被修复,

/usr/bin/dbus-uuidgen > /etc/machine-id
dbus-uuidgen >/var/lib/dbus/machine-id
apt update
apt dist-upgrade

输出

root@vps:~# apt dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libcbor0 libicu67 libldap-2.4-2 libmpdec3 libperl5.32 libpython3.9-minimal libpython3.9-stdlib liburing1 libusb-0.1-4
  perl-modules-5.32 python3.9 python3.9-minimal telnet
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up dbus-daemon (1.14.6-1) ...
Setting up dbus (1.14.6-1) ...
A reboot is required to replace the running dbus-daemon.
Please reboot the system when convenient.
dbus.service is a disabled or a static unit, not starting it.
Setting up libpam-systemd:amd64 (252.6-1) ...
Setting up dbus-user-session (1.14.6-1) ...

现在,使用以下命令删除未使用的包,

apt autoremove -y

4. 升级后验证Debian 12

升级过程完成后,请重新启动计算机并检查版本。

root@vps:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:    12
Codename:   bookworm

检查 OS-release 文件

root@vps:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

到这里,VPS服务器正在运行Debian 12.

原创文章,作者:zhuji001,如若转载,请注明出处:https://www.zhuji66.com/upgrade-debian-11-to-debian-12/

本站分享VPS和云服务器信息均来源于网络,如有侵权请邮箱联系zhuji66com@yeah.net。本站不销售任何产品,如遇问题请联系对应客服。