阿里云服务器从 Debian 11 升级 Debian 12
前言
笔者近期在阿里云上购买了一台 2c/2g 的轻量应用服务器,在配置界面发现阿里云提供的服务器镜像中 Debian 系统的版本还停留在 11.3,出于系统安全和个人习惯考虑,笔者决定先安装 Debian 11.3,再设法升级到最新的稳定版 Debian 12.8。
笔者本来准备使用之前博客中介绍过的 iPXE 给服务器重装系统,但是在查询 Debian 12 发行手册的时候发现其中提供了从 Debian 11 手动升级的详细说明,遂决定一试。
升级步骤
首先,运行以下命令将 Debian 11 更新到最新版本:
sudo apt update
sudo apt upgrade
sudo apt full-upgrade
sudo apt autoremove
然后,记录一下系统当前的版本信息:
使用以下命令妥善备份 apt 配置文件:
sudo cp -v /etc/apt/sources.list ~/backup/
sudo cp -vr /etc/apt/sources.list.d/ ~/backup/
打开 /etc/apt/sources.list
文件,以下是修改之前的文件内容:
使用 Debian 12 的发行代号 bookworm
替换文件中的 bullseye
,并在原有条目末尾新增 non-free-firmware
仓库,修改后的 sources.list
文件内容如下:
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm main contrib non-free non-free-firmware
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm-updates main contrib non-free non-free-firmware
deb http://mirrors.cloud.aliyuncs.com/debian/ bookworm-backports main non-free contrib non-free-firmware
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm main contrib non-free non-free-firmware
deb-src http://mirrors.cloud.aliyuncs.com/debian/ bookworm-backports main contrib non-free non-free-firmware
deb http://mirrors.cloud.aliyuncs.com/debian-security/ bookworm-security main non-free contrib non-free-firmware
deb-src http://mirrors.cloud.aliyuncs.com/debian-security/ bookworm-security main non-free contrib non-free-firmware
运行以下命令开始升级:
sudo apt update
sudo apt full-upgrade
升级过程中可能会出现类似下图的配置界面:
仔细阅读说明后根据实际情况选择,大部分情况下直接保留原有配置或使用默认选项即可。
验证与清理
升级完成后重启系统,再次查看系统版本信息以验证是否升级成功:
可以看到我们成功从 Debian 11.11 升级到了最新的稳定版 Debian 12.8,内核版本也升级到了 Debian 6.1.0。确认升级成功后运行 sudo apt --purge autoremove
命令清理不必要的软件包以及之前升级过程中产生的临时文件:
最后,对于经常使用阿里云的用户,可以基于服务器的当前状态创建自定义镜像以用作 Debian 12.8 系统的基础镜像。
参考资料
暂无标签
阿里云服务器从 Debian 11 升级 Debian 12
https://blog.jjl9807.com/archives/33/