1.设置软件源
cat > /etc/apt/sources.list<<EOF
deb http://archive.debian.org/debian/ stretch main contrib non-free
deb-src http://archive.debian.org/debian/ stretch main contrib non-free
deb http://archive.debian.org/debian-security/ stretch/updates main contrib non-free
deb-src http://archive.debian.org/debian-security/ stretch/updates main contrib non-free
deb http://archive.debian.org/debian/ stretch-backports main contrib non-free
EOF
2.升级Debian 9 现有的软件包
apt update && apt upgrade -y
3.提示GPG证书问题,NO_PUBLICKEY
记录PUBULICKEY
NO_PUBKEY 648ACFD622F3D138 NO_PUBKEY 0E98404D386FA1D9
3.1安装需要的依赖和软件
apt-get install software-properties-common dirmngr -y
3.2添加gpg证书验证
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <PUBKEY>
<PUBKEY2>
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138 0E98404D386FA1D9
4.更换debian12的软件源
cat >/etc/apt/sources.list<<EOF
deb https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb-src https://mirrors.ustc.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
EOF
添加公钥
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 54404762BBB6E853 BDE6D2B9216EC7A8
5.更新软件源索引
apt update -y
在开始升级你现有的 Debian 操作系统前,让我们使用下面的命令验证当前版本
cat /etc/*-release
6.从 Debian 9 升级到 Debian 12
apt update && apt upgrade -y
7.查看当前版本信息
lsb_release -a