从 Debian 10 升级到 11
Debian 11 发布了,这两天把几个服务器升级测试一下效果。
博客所在的服务器已经升级了,体验起来没有什么大问题。
把执行的指令记录了一下。升级过程中的下线时间大概在半小时到一小时之间。
# 可选: 开启记录,方便差错
script -t 2>~/upgrade-bullseye.time -a ~/upgrade-bullseye.script
# scriptreplay ~/upgrade-bullseye.time ~/upgrade-bullseye.script
# 更新系统的包到最新
apt update
apt full-upgrade
# 修改系统的新源
# 注意: “debian-security buster/updates main” 要变成 “debian-security bullseye-security/updates main”
sed -i 's/buster/bullseye/g' /etc/apt/sources.list
sed -i 's#debian-security bullseye/updates main#debian-security bullseye-security/updates main#g' /etc/apt/sources.list
# backports
if [ -f /etc/apt/sources.list.d/buster-backports.list ]; then
sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/buster-backports.list
mv /etc/apt/sources.list.d/{buster,bullseye}-backports.list
fi
# node.js
if [ -f /etc/apt/sources.list.d/nodesource.list ]; then
sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/nodesource.list
fi
# docker
if [ -f /etc/apt/sources.list.d/download_docker_com_linux_debian.list ]; then
curl -fsSL https://download.docker.com/linux/debian/gpg |\
gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
rm /etc/apt/sources.list.d/download_docker_com_linux_debian.list
elif [ -f /etc/apt/sources.list.d/docker.list ]; then
sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/docker.list
fi
# 之前配置的奇怪的地址修正…
sed -i 's#security.debian.org bullseye/updates main#security.debian.org/debian-security bullseye-security/updates main#g' /etc/apt/sources.list
# 更新,注意手动确认是否需要替换为包维护者的配置文件。
apt update
apt full-upgrade --autoremove
# 检查下是否需要手动替换或删除的配置文件:
find /etc -xdev -name '*.dpkg-new'
find /etc -xdev -name '*.dpkg-old'
# sshd_config: Port 行前加入 "Include /etc/ssh/sshd_config.d/*.conf"
sed -i '/^Port /i Include /etc/ssh/sshd_config.d/*.conf' /etc/ssh/sshd_config
# 替换 PHP 7.3 到 7.4 (可惜官方源还没有 8)
# 然后重启 nginx
grep -Rl 'php7\.3-fpm' /etc/nginx |\
xargs --no-run-if-empty -- sed -i 's/php7\.3-fpm/php7\.4-fpm/g'
nginx -s reload
# 如果机器内存 < 512MB 则禁用 dpkg 的清理任务
< /proc/meminfo awk '$1 == "MemTotal:" && $2 > 524288 { exit 1 }' && \
mv /etc/cron.daily/dpkg{,.disabled}
# 如果需要升级 Docker@buster 的包到 bullseye
# apt --reinstall install docker-ce=5:20.10.8~3-0~debian-bullseye docker-ce-cli=5:20.10.8~3-0~debian-bullseye containerd.io=1.4.9-1
# 检查下 SSH 能否正常登入,然后重启
# reboot
# 检查下 dkms 模块是否都加载了(如果有)
command -v dkms && dkms status