云梦
www.htcp.net

Debian 8 以 dist-upgrade 的方式升级至 Debian 9

介绍

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?

如果在升级过程中碰到了询问一些配置文件是否要进行覆盖,您可新开一个窗口,将旧版配置文件复制先出来,然后再回到升级窗口,输入「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

这样就好了,大功告成。

赞(6) 打赏
文章通过 CC 4.0 BY-NC-ND 协议发布,转载请注明出处:云梦 » Debian 8 以 dist-upgrade 的方式升级至 Debian 9

评论 3

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #2

    最喜欢这种给小白看的文章了,博主帮大忙了,感谢!!

    爱你哟5年前 (2019-08-06)回复
  2. #1

    什么做生产环境好呢?ubuntu debian centos

    Chaso6年前 (2018-02-23)回复

如果您觉得文章有用,可以支持一下本站

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏