树莓派3B+ apt-get update 出错记录

树莓派3B+ apt-get update 出错记录

sudo apt-get update 出错:

1
2
3
4
5
6
7
8
E: 无法下载 http://101.44.1.125/files/B11600000762A811/mirrors.zju.edu.cn/debian/dists/stretch/main/binary-armhf/Packages.gz  Writing more data than expected (184092 > 174269)
Hashes of expected file:
- Filesize:174269 [weak]
- SHA256:949a940146e8a41829afee9a301507d59389c27c82d7a42eba4523b121648980
- SHA1:1b4f8b91ab3041de7eba7c4b5c1c9d3e20000967 [weak]
- MD5Sum:2e03359b53821e9e71414a2c1f579c75 [weak]
Release file created at: Wed, 05 Sep 2018 15:09:54 +0000
E: 部分索引文件下载失败。如果忽略它们,那将转而使用旧的索引文件。

更镜像源地址为中国科技大学:

  1. sudo nano /etc/apt/sources.list

    原文件:

    1
    2
    3
    deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    # deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

    修改为:

    1
    2
    3
    4
    5
    deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
    # deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    # deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

    注意实际上只是把网址变了,后面部分不变,因为我看到以前的系统后面部分是不一样的。

  2. sudo nano /etc/apt/sources.list.d/raspi.list
    原文件:

    1
    2
    3
    deb http://archive.raspberrypi.org/debian/ stretch main ui
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    #deb-src http://archive.raspberrypi.org/debian/ stretch main ui

    修改为:

    1
    2
    3
    4
    5
    deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
    deb-src http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
    # deb http://archive.raspberrypi.org/debian/ stretch main ui
    # Uncomment line below then 'apt-get update' to enable 'apt-get source'
    #deb-src http://archive.raspberrypi.org/debian/ stretch main ui

再次尝试更新:

sudo apt-get update 没问题。
sudo apt-get upgrade出错:

1
2
3
4
5
6
7
8
9
10
11
12
E: 无法下载 http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/pool/main/f/ffmpeg/libavutil55_3.2.10-1~deb9u1+rpt2_armhf.deb  Hash 校验和不符
Hashes of expected file:
- SHA256:7461952290100c547db476ac7e2b3b727808a12060b0811490b42f2ad5f014d0
- SHA1:f79cb9b0ccf2375268fa9f27d60e8b1032a2ad77 [weak]
- MD5Sum:97cebd03678913ec7777cdc09602460b [weak]
- Filesize:234328 [weak]
Hashes of received file:
- SHA256:39043f5c516b326e2ced462aa3429c117c29831773e77440888c033c611ee3d0
- SHA1:bf444ace211d2f455b9cee540055786e6fd6bb6b [weak]
- MD5Sum:e6b2bd3e40e2c90651562ff882aa7d3f [weak]
- Filesize:234328 [weak]
Last modification reported: Wed, 01 Aug 2018 11:56:50 +0000
1
E: 无法下载 http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/pool/main/f/ffmpeg/libavcodec57_3.2.10-1~deb9u1+rpt2_armhf.deb  无法发起与 mirrors.ustc.edu.cn:80 (2001:da8:d800:95::110) 的连接 - connect (101: 网络不可达) [IP: 2001:da8:d800:95::110 80]

再次修改配置

怀疑是/etc/apt/sources.list和/etc/apt/sources.list.d/raspi.list里面配置的源不一致,网上查了下sources.list.d目录下是配置第三方软件源。部里面内容全部注释掉,再次更新:
sudo apt-get update 有很多更新
sudo apt-get upgrade 没有任何软件升级,不知道对不对,但是至少没有错误了:

1
2
3
4
5
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
正在计算更新... 完成
升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。