跳到主要内容

从Debian10升级到Debian12

有些服务器的镜像只提供安装Debian10,这是一篇从纯净Debian10升到Debian12的笔记。

从Debian10升到11

先确认小版本是否还需要升级

apt update
apt upgrade

清理配置文件残留

find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'

更新sources.list

Debian11开始安全更新仓库变了,从buster/updates变更为了bullseye-security,在更新source.list的时候要注意。

先看服务器需要的是什么种类的仓库,比如

deb http://mirrors.online.net/debian buster main non-free contrib
deb-src http://mirrors.online.net/debian buster main non-free contrib

deb http://security.debian.org/debian-security buster/updates main contrib non-free
deb-src http://security.debian.org/debian-security buster/updates main contrib non-free

就可以知道它需要mainnon-freecontrib,那么更新之后除了main也要加上后面这两个。

sources.list该怎么写?

sources.list的写法可以参考:https://wiki.debian.org/SourcesList

Debian镜像地址可以在 https://www.debian.org/distrib/ftplist 找到

比如确定了一个法国的源 http://ftp.fr.debian.org/debian/ 你可以在dists/目录下看到

  • bullseye/:为 Debian 11 的标准软件包提供稳定支持和安全更新。
  • bullseye-updates/:提供了发行版发布后需要的非安全更新。
  • bullseye-backports/:允许用户安装更新的软件版本,这些版本来自于 Debian 的下一个测试版,但被重新编译以适配当前的稳定版。

安全更新仓库不在debian/dist/目录下

安全更新仓库在和debian同一级的security-updates目录下,这个目录下有个dist目录,进去可以看到bullseye-security/这个文件夹。

接下来的例子是按照这个源来写的。

更新后的sources.list是这样的

deb http://ftp.fr.debian.org/debian/ bullseye main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye main non-free contrib

deb http://ftp.fr.debian.org/debian/ bullseye-updates main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye-updates main non-free contrib

deb http://ftp.fr.debian.org/debian/ bullseye-backports main non-free contrib
deb-src http://ftp.fr.debian.org/debian/ bullseye-backports main non-free contrib

deb http://ftp.fr.debian.org/debian-security/ bullseye-security main non-free contrib
deb-src http://ftp.fr.debian.org/debian-security/ bullseye-security main non-free contrib

按下来先更新源

apt update

然后最小升级

apt upgrade --without-new-pkgs

最后是完整升级

apt full-upgrade

从Debian11升到12

和从10到11的方法大同小异,因为是刚从10升到11,所有东西应该都是最新的,只需要更新sources.list,然后更新源,再最小升级,最后完整升级。 从12之后non-free被拆分成了non-freenon-free-firmware,所以要加上non-free-firmware

信息

https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.html#non-free-split

5.1.1. Non-free firmware moved to its own component in the archive As described in Section 2.2, “Archive areas”, non-free firmware packages are now served from a dedicated archive component, called non-free-firmware. To ensure installed non-free firmware packages receive proper upgrades, changes to the APT configuration are required. Assuming the non-free component was only added to the APT sources-list to install firmware, the updated APT source-list entry could look like:

deb https://deb.debian.org/debian bookworm main non-free-firmware

更新后的sources.list是这样的

deb http://ftp.fr.debian.org/debian/ bookworm main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm main non-free non-free-firmware contrib

deb http://ftp.fr.debian.org/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm-updates main non-free non-free-firmware contrib

deb http://ftp.fr.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian/ bookworm-backports main non-free non-free-firmware contrib

deb http://ftp.fr.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib
deb-src http://ftp.fr.debian.org/debian-security/ bookworm-security main non-free non-free-firmware contrib

按下来先更新源

apt update

然后最小升级

apt upgrade --without-new-pkgs

最后是完整升级

apt full-upgrade
注意

为了防止SSH登录失败,重启之前最好先检查一下SSHD的配置文件有没有语法错误。

sshd -t

检查升级是否成功

uname -mrs
Output: Linux 6.1.0-17-amd64 x86_64

补充说明

contrib

  • 定义:contrib仓库包含的是那些自身是自由的软件,但是依赖于non-free仓库中的软件包才能运行的软件。虽然contrib中的软件本身遵守自由软件的准则,但由于它们依赖的软件不是完全自由的,所以被放在这个特殊的分类中。
  • 示例:一个游戏可能是自由的并且源代码是开放的,但如果它需要一个非自由的游戏引擎才能运行,那么这个游戏就会被归类到contrib

non-free

  • 定义:non-free仓库包含的是那些不完全符合自由软件准则的软件。这些软件可能限制了修改或再分发的权利,或者以某种方式限制了使用。non-free并不意味着软件需要付费(虽然有些确实如此),而是指它们在许可证上有一些限制,不满足Debian自由软件准则的要求。
  • 示例:一些驱动程序,专有软件或受版权保护的游戏就可能被放在non-free仓库中。

non-free-firmware

non-free-firmwareDebian 12 (Bookworm)发布准备过程中引入的一个新的仓库组件,专门用于存放那些非自由的固件。固件通常是预写入硬件设备中的软件程序,用于控制或使硬件设备运作。在很多情况下,硬件设备(如网卡、显卡等)需要特定的固件才能在Linux系统上正常工作。

将非自由固件分离到自己的仓库组件 non-free-firmware 的目的是为了清晰地区分完全自由的软件包和需要由于实用原因而包含的非自由固件。这样做允许Debian更好地组织和管理这些固件,同时也使得创建只包含自由软件但能够支持广泛硬件的安装镜像成为可能。