やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

Raspbianでaptのミラーサーバを日本にしてupdateを高速化

 sudo apt-get updateが遅いので。

対象環境

方法

  1. ミラーサーバを調べる
  2. サーバの応答速度を調べる
  3. 設定ファイルを変更する

手段

1. ミラーサーバを調べる

 2018-09-10時点では以下のサーバがあった。

2. サーバの応答速度を調べる

 別に調べなくてもいいけど。

$ curl -sL ${url} -o /dev/null -w "%{time_total}ms"

日本サーバ

$ curl -sL http://ftp.jaist.ac.jp/raspbian -o /dev/null -w "%{time_total}ms"
$ curl -sL http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ -o /dev/null -w "%{time_total}ms"
$ curl -sL http://ftp.yz.yamagata-u.ac.jp/pub/linux/raspbian/raspbian/ -o /dev/null -w "%{time_total}ms"
0.151ms
0.111ms
1.585ms

ファームウェア用サーバ

$ curl -sL http://mirrordirector.raspbian.org/raspbian/ -o /dev/null -w "%{time_total}ms"
0.013ms

初期サーバ

$ curl -sL http://archive.raspbian.org/raspbian/ -o /dev/null -w "%{time_total}ms"
0.013ms

 あれ、こっちのほうが速い。なぜだ。sudo apt-get updateしたら遅いんだけどな。

3. 設定ファイルを変更する

/etc/apt/sources.list

$ sudo leafpad /etc/apt/sources.list

before

# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi

after

deb http://ftp.jaist.ac.jp/raspbian/ jessie main contrib non-free rpi
deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ jessie main contrib non-free rpi
deb http://ftp.yz.yamagata-u.ac.jp/pub/linux/raspbian/raspbian/ jessie main contrib non-free rpi
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
# firmwar update
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ jessie main ui
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ jessie main contrib non-free rpi

 ちなみに、stretchなら以下。

deb http://ftp.jaist.ac.jp/raspbian/ stretch main contrib non-free rpi
deb http://ftp.tsukuba.wide.ad.jp/Linux/raspbian/raspbian/ stretch main contrib non-free rpi
deb http://ftp.yz.yamagata-u.ac.jp/pub/linux/raspbian/raspbian/ stretch main contrib non-free rpi
deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi
# firmwar update
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
deb http://ftp.jaist.ac.jp/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

参考