急いでいるときに、すこしでもaptを速くしたい
apt の src を高速なミラーとかローカルミラーを使えば少し早くなる。んだけど、それだけだとまだ足りない。
Aptで余計なものを入れなければいいんだと思うんですよね。
apt.conf にrecommends と suggestを除外する設定を書く
tee を使って apt に no-recommends と no-suggests を書き込む
echo -e "APT::Install-Suggests 0;\nAPT::Install-Recommends 0;" | sudo tee /etc/apt/apt.conf.d/00-no-install-recommends
実際にコマンドを実行するとこんな感じ.
takuya@ubuntu01:/etc/apt/apt.conf.d$ echo -e "APT::Install-Suggests 0;\nAPT::Install-Recommends 0;" | sudo tee /etc/apt/apt.conf.d/00-no-install-recommends APT::Install-Suggests 0; APT::Install-Recommends 0;
最後に設定が有効になったか確認
apt の設定が有効になったかは、apt-config コマンドを使えばわかる。 recommends と suggest が有効になったのがわかる。
takuya@ubuntu01:/etc/apt/apt.conf.d$ apt-config dump | grep Install APT::Install-Recommends "0"; APT::Install-Suggests "0"; DPkg::Pre-Install-Pkgs ""; DPkg::Pre-Install-Pkgs:: "/usr/sbin/dpkg-preconfigure --apt || true"; AptCli::Hooks::Install ""; AptCli::Hooks::Install:: "[ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true";
ついでに ミラーサーバも設定しておく
URL=http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ sed -i "s|http://archive.ubuntu.com/ubuntu/|${URL}|" /etc/apt/sources.list
または mirror+http://mirrors.ubuntu.com/mirrors.txt
を使う。
コピペ用
sudo su echo -e "APT::Install-Suggests 0;\nAPT::Install-Recommends 0;" | tee /etc/apt/apt.conf.d/00-no-install-recommends URL=http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ sed -i -r "s|http://(jp.)?archive.ubuntu.com/ubuntu/?|${URL}|" /etc/apt/sources.list sed -i "s|http://security.ubuntu.com/ubuntu/?|${URL}|" /etc/apt/sources.list apt update apt upgrade
参考資料
man apt-config