Debian 11升级到Debian 12详细指南
随着CentOS逐渐退出历史舞台,越来越多的用户开始选择Debian作为服务器系统。如今,Debian 12(代号Bookworm)已经发布,如果你还在使用Debian 11,不妨尝试一下升级体验新版本。下面将为大家介绍一个简单、快速的升级流程。
一、更新现有系统
在进行大版本升级前,建议先把当前系统的软件包和安全补丁全部更新到最新状态。在终端中执行以下命令:
apt update && apt upgrade
二、更换软件源为Debian 12
根据你的服务器所在地区,可以选择不同的软件源以提升下载速度和稳定性。
- 如果你的服务器位于中国大陆或香港地区,推荐使用华为云镜像源。执行如下命令替换sources.list文件:
cat > /etc/apt/sources.list << EOF
deb https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian-security/ bookworm-security main
deb-src https://mirrors.huaweicloud.com/debian-security/ bookworm-security main
deb https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm-updates main non-free non-free-firmware contrib
deb https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib
deb-src https://mirrors.huaweicloud.com/debian/ bookworm-backports main non-free non-free-firmware contrib
EOF
- 若服务器位于欧美等其他地区,可选用Linode提供的镜像源:
cat > /etc/apt/sources.list << EOF
deb http://mirrors.linode.com/debian bookworm main non-free-firmware
deb-src http://mirrors.linode.com/debian bookworm main non-free-firmware
deb http://mirrors.linode.com/debian-security/ bookworm-security main non-free-firmware
deb-src http://mirrors.linode.com/debian-security/ bookworm-security main non-free-firmware
deb http://mirrors.linode.com/debian bookworm-updates main non-free-firmware
deb-src http://mirrors.linode.com/debian bookworm-updates main non-free-firmware
EOF
三、再次更新并进行全面升级
更换完软件源后,需要重新刷新本地软件包索引,并执行完整升级操作:
apt update && apt full-upgrade
在此过程中可能会遇到一些提示或交互,例如要求输入“q”退出查看变更说明,其余步骤一般直接输入“y”确认即可。
四、重启系统完成升级
待所有安装与配置过程结束后,通过下述命令重启系统,使所有新内核及服务生效:
reboot
经过以上几个步骤,你的服务器就顺利从Debian 11升级到了全新的Debian 12。如果遇到特殊依赖问题或者自定义配置较多,请提前做好数据备份,以防万一。
信息参考来源:debian官方文档及相关社区经验分享