红联Linux门户
Linux帮助

Debian版本升级/降级

发布时间:2016-02-11 10:26:27来源:worldhello.net作者:linux人

最近笔记本的 Debian 系统不太正常,总是在程序切换的时候键盘丢失。例如从浏览器切换到 konsole 时,无法输入,在 konsole 中通过创建新标签并在不同标签页中切换后,才能够继续输入... 这个问题很是困扰,联想到最近从 sid (Debian 不稳定发行版)做了升级,难道是升级后出现的 bug?


题外话:查看磁盘空间,是否有分区已满
实际上,这应该是当系统出现异常后,率先进行检查的。但是由于我的疏忽在Debian降级过程中,才发现 /var 卷已满,当执行 apt-get clean 命令后,释放了 5 GB以上的空间。 所以程序切换键盘丢失,到底是因为 Debian 从不稳定版升级造成的,还是因为 /var 卷已满造成的,已经查无实据。


Debian 混杂版本
所谓 Debian 混杂版本,就是在一个 debian 系统中,安装的软件包不属于同一个发行版(distribution),有的可能属于 stable(当前代号是 lenny),有的属于 testing (当前代号 squeeze),或者有的软件包属于不稳定版(代号 sid)。 Debian 的 APT 可以设置升级的默认发行版。可以创建一个文件,如: /etc/apt/apt.conf.d/01defaultrelease ,其内容为:

APT::Default-Release "testing";
APT::Cache-Limit "141943904";

这样在用 aptitude 升级时,默认从 testing 版本进行升级;


Debian 版本升级
Debian 版本升级非常简单:

在 /etc/apt/apt.conf.d/01defaultrelease 中设置默认发行版。

APT::Default-Release "unstable";
APT::Cache-Limit "141943904";

然后,正确配置 /etc/apt/sources.list 中的升级源。例如:

deb http://mirror.cs.umn.edu/debian/ lenny main contrib non-free
deb http://mirror.cs.umn.edu/debian/ testing main contrib non-free
deb http://mirror.cs.umn.edu/debian/ unstable main contrib non-free
deb http://mirror.cs.umn.edu/debian/ experimental main contrib non-free
deb http://security.debian.org/ stable/updates main
deb http://security.debian.org/ testing/updates main

最后,执行命令:

$ sudo aptitude update
$ sudo aptitude dist-upgrade


Debian 版本降级
Debian 版本降级相比升级,要难许多。试着通过修改 APT 的 Default-Release,然后用 aptitude dist-upgrade,但是无法满足降级的需要。可以用下面的方法实现降级:

在 /etc/apt/apt.conf.d/01defaultrelease 中设置默认发行版。
然后,正确配置 /etc/apt/sources.list 中的升级源。
执行 apt-get update 更新源的软件包列表。
查看当前软件包安装情况:安装了哪些软件包,分别属于哪个发行版,版本号是什么?

$ apt-show-version > apt-show-version.list

查看文件 apt-show-version.list,筛选出需要降级的软件包,再一一手动进行降级。降级可能需要使用命令:
apt-cache policy <PACKAGE>
aptitude install <PACKAGE>=<VERSION>


后记
关于输入焦点丢失,键盘输入不响应的问题,其实并没有在此次 Debian 版本降级(sid --> testing)的过程解决。如果从sid 降级到 lenny,应该能够解决,但是我实在是舍不得 KDE4 的 3D 桌面等特效。最终这个问题的解决,参见博客:Linux 应用程序失去输入焦点问题的解决(http://www.linuxdiyf.com/linux/18005.html)。


本文永久更新地址:http://www.linuxdiyf.com/linux/18004.html