By accessing the website and accepting the Cookie Policy, you agree to use the cookies provided by the Site in accordance with to analyze traffic, remember your preferences, and optimize your experience.
Debian 8 以 dist-upgrade 的方式升级至 Debian 9
2018-11-23 17:07:33    166    0    0
emengweb

介绍

Debian 9 已经稳定好几个月了,可以作为生产环境使用了。下面将介绍,如何免使用格式化,直接通过 dist-upgrade 的方式直接升级至 Debian 9。

首先注意,您的系统上的,通过自编译生成的二进制程序,例如 PHP、Nginx 等,升级后可能无法使用,请在升级之后,重新编译它们。

建议您先在测试环境上测试您的生产工具完全可用后,再执行升级。

升级步骤

以下步骤请使用 Root 账户进行操作。

1. 执行系统更新

首先保证当前安装的所有程序版本是当前 Debian 发行版本中最新的。

apt-get update -yq && apt-get upgrade -yq && apt-get dist-upgrade -yq

2. 将安装源切换至 stretch

一条命令搞定:

sed -i 's@jessie@stretch@g' /etc/apt/sources.list

3. 开始升级

apt-get update -yq && apt-get upgrade -yq && apt-get dist-upgrade -yq

接下来会显示一个窗口,询问是否自动重启服务,选「Yes」即可。

x There are services installed on your system which need to be restarted when certain x
x libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may x
x cause interruptions of service for the system, you will normally be prompted on x
x each upgrade for the list of services you wish to restart. You can choose this x
x option to avoid being prompted; instead, all necessary restarts will be done for x
x you automatically so you can avoid being asked questions on each library upgrade. x
x x
x Restart services during package upgrades without asking?

如果在升级过程中碰到了询问一些配置文件是否要进行覆盖,安全起见,建议选择N。

当然,您也可新开一个窗口,将旧版配置文件复制先出来,然后再回到升级窗口,输入「Y」选择 install the package maintainer's version 继续,升级完毕后再对比新旧配置文件的差异,找出自己修改过的部分,重新配置该程序的配置文件。

4. 删除旧的应用包

首先通过如下命令删除旧的软件包:

apt autoremove -yq

然后清理残留的孤立软件包:

oldPkg="$(dpkg -l | grep -n '^rc' | awk '{print $2}')"
apt purge -y ${oldPkg}

5. 重启系统

reboot

6. 清理旧的内核

首先列出所有安装的内核和内核头文件:

dpkg -l | grep linux-image
dpkg -l | grep linux-headers

找出列表中自己不需要的旧内核并卸载:

例如以卸载 linux-image-3.16.0-5-amd64 为例

apt purge -y linux-image-3.16.0-5-amd64

这样就好了,大功告成。

上一篇: 在Debian 9 (Stretch) 上安装Docker Engine

下一篇: Hetzner独服使用Proxmox创建VPS

166 人读过
文档导航