11

Debian更新源时发生两个错误

 3 years ago
source link: https://note.qidong.name/2017/06/26/debian-apt-source-errors/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Debian更新源时发生两个错误

2017-06-26 17:42:13 +08  字数:554  标签: Linux

今日,孤在Debian上执行sudo apt-get update时发生两个问题。

问题一

现象

E: Some index files failed to download. They have been ignored, or old ones used instead.

这个错误,通常伴随着一些形如下面的警告:

W: Failed to fetch http://…/ 404 Not Found [IP: xxx.x.x.xxx 80]

原因

更新源时,如果出问题,通常会有两种可能。

  1. 新源有问题,或部分版本无法访问。比如,无法访问Scretch,但能访问Jessie。
  2. 原先的一些自增源,年久失修,无法访问。比如,http://ppa.launchpad.net/*里的源。

解决方案

针对上述第一种情况,换源时,推荐使用apt-spy

apt-spy会根据参数,对指定区域内的源进行测速, 并且把推荐的源写在/etc/apt/sources.list.d/apt-spy.list中。

以下在亚洲,对stable源进行测速,时限3秒。

sudo apt-spy -d stable -s asia -t 3
sudo cp /etc/apt/sources.list.d/apt-spy.list /etc/apt/sources.list

这样通常可以解决第一个问题。

如果还是不行,使用ftp://ftp.cn.debian.org/debian/, 往往是中国区的默认方案,速度普通,胜在稳定。

针对第二种情况,需要把一些不用的、一次性的源删除。

如果没有需要保留的自增源,可以直接删除全部。

sudo rm -rf /etc/apt/sources.list.d/*

再次使用apt-get update更新即可。

问题二

现象

W: There is no public key available for the following key IDs:

原因

错误的key,或者老旧的keyring版本。

解决方案

sudo apt-get install debian-keyring debian-archive-keyring
sudo apt-key update
sudo apt-get update

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK