Debian 11 Bullseye 升级 Debian 12 Bookworm
本文最后更新于 565 天前, 如有失效请评论区留言.
本文主要记录Debian 11 Bullseye 升级 Debian 12 Bookworm
前提
- 升级前先快照
- 不支持LXC
- Debian 11
更新Debian11
升级前先确定是否为Debian 11
root@cn-bj-r1.ysicing.local:~$ 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/"
更新当前系统到最新版本
apt update
apt upgrade -y
apt dist-upgrade -y
apt autoclean
apt autoremove -y
更新软件源
- 仅变更
/etc/apt/sources.list
- 由于Debian 12及以后的版本,支持分发非自由固件二进制文件(
non-free
),如部分驱动,都被转移到新组件目录: 非自由固件(non-free-firmware
)
命令行操作
操作如下
# 替换 bullseye 为 bookworm
sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*.list
# 新增 non-free-firmware 可选, 但建议
sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list
重写文件
重写/etc/apt/sources.list
cat > /etc/apt/sources.list <<EOF
deb http://mirrors.tencent.com/debian/ bookworm main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian/ bookworm-proposed-updates main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
腾讯云内网
cat > /etc/apt/sources.list <<EOF
deb http://mirrors.tencentyun.com/debian/ bookworm main contrib non-free non-free-firmware
deb http://mirrors.tencentyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.tencentyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://mirrors.tencentyun.com/debian/ bookworm-proposed-updates main contrib non-free non-free-firmware
deb http://mirrors.tencentyun.com/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
升级系统
完成上述操作后,再次执行更新系统命令
用Debian都知道的
- 更新过程种会提示一些软件是否需要自动重启,选 Yes 即可,以及一些软件的配置文件是否需要更新,按照自己的情况选择即可,默认回车即视为使用旧的配置文件
- 另外有些软件会提示是否变更配置, 默认选择
keep the local version
即可
apt update
apt upgrade -y
apt dist-upgrade -y
# 在升级完成没报错后执行,也可以在reboot后执行
apt autoclean
apt autoremove -y
reboot
确定查看系统版本
root@cn-bj-r1.ysicing.local ~ # cat /etc/debian_version
12.0
确定查看系统版本
root@cn-bj-r1.ysicing.local:~$ uname -a
Linux cn-bj-r1.ysicing.local 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux