Raspberry Pi Raspbianでapt-getがうまくいかないときの対処法

サーバー構築Raspberry Pi,Raspbian

 

Raspbianな環境でapt-get updateをかけてみたところ、次のようなエラーが発生してしまった。

$ sudo apt-get upgrade
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/b/base-files/base-files_10.3+rpi1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]           
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/b/bzip2/bzip2_1.0.6-9.1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/b/bzip2/libbz2-1.0_1.0.6-9.1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/systemd/systemd-sysv_241-5+rpi1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/s/systemd/libpam-systemd_241-5+rpi1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]
E: Failed to fetch http://raspbian.raspberrypi.org/raspbian/pool/main/o/openssl/libssl-dev_1.1.1c-1_armhf.deb  404  Not Found [IP: 93.93.128.193 80]

apt-get updateをすれば良いじゃないか、と思われるかも知れないが、そもそもその段階から404 NOT FOUND。
その前の段階では、次のようなメッセージが出ていた。

$ sudo apt-get update
Get:1 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Hit:2 http://archive.raspberrypi.org/debian buster InRelease
Reading package lists... Done
E: Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'testing' to 'stable'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

ようするに、Busterが正式にリリースされたので、これをうけてBusterをTestingではなくStableとして認識するよう設定を変更しなさい、ということだ。

まずは上記の問題に対応する

上記に対応するためには、単純に以下のコマンドを発行すれば良い。

sudo apt-get update --allow-releaseinfo-change

リリースが変更となったことを許容してupdateをかける、の意である。
しかし、こういうことが起こると公式へのアクセスが殺到してしまうため、ミラーサイトを探して使うことが良いだろう。

ミラーサイトを探す

raspberrypiの公式サイトはたまに上記のような事象が発生してしまうそうだ。そのため、多くのミラーサイトが用意されている。

このミラーサイトの中から、高速そうなところを探してaptのホストとして用いるのがよさそうである。

今回は、このうちJAISTが提供しているもの(http://ftp.jaist.ac.jp/raspbian/)を利用することにした。

/etc/sources.listを編集する

次のように、ミラーサイトを使うように変更をした。

deb http://ftp.jaist.ac.jp/raspbian/ buster main contrib non-free rpi
deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ buster main contrib non-free rpi

これでこのような問題は発生しなくなった。

Posted by webnetforce