10
6

More than 3 years have passed since last update.

apt installのトラブルシューティング

Posted at

環境

Vagrant + Ubuntu 16.04.5 LTS

はじめに

ntpdateをaptでインストールしようとした時に発生したエラーのトラブルシューティングです。

参考
https://kaworu.jpn.org/ubuntu/Ubuntu%E3%81%AE%E4%B8%8D%E8%A6%81%E3%81%AA%E3%83%91%E3%83%83%E3%82%B1%E3%83%BC%E3%82%B8%E3%82%92%E5%89%8A%E9%99%A4%E3%81%99%E3%82%8B

手順

ntpdateをaptでインストールしてみた。

$ sudo apt install ntpdate

すると、このようなエラーが出てくる。

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:

  ・・・・(不要なパッケージがずらずら表示)

Use 'sudo apt autoremove' to remove them.

必要とされていないパッケージが存在していると、インストール時に、このようなメッセージが表示されるようです。不要なパッケージをいつまでも置いておくと、セキュリテイ的に良くないのと、ディスク容量を圧迫する事になるため、削除しなくてはいけません。削除する方法は、エラーメッセージをよく読むと書いてあります。

不要なパッケージが一括削除されます。

$ sudo apt autoremove

再度、インストールしてみる。

$ sudo apt install ntpdate

最初のエラーはなくなったが、他のエラーが出てくる。

The following NEW packages will be installed:
  ntpdate
0 upgraded, 1 newly installed, 0 to remove and 88 not upgraded.
Need to get 48.6 kB of archives.
After this operation, 173 kB of additional disk space will be used.
Err:1 http://security.ubuntu.com/ubuntu xenial-security/main amd64 ntpdate amd64 1:4.2.8p4+dfsg-3ubuntu5.9
  404  Not Found [IP: 91.189.88.152 80]
Err:1 http://security.ubuntu.com/ubuntu xenial-security/main amd64 ntpdate amd64 1:4.2.8p4+dfsg-3ubuntu5.9
  404  Not Found [IP: 91.189.88.152 80]
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/n/ntp/ntpdate_4.2.8p4+dfsg-3ubuntu5.9_amd64.deb  404  Not Found [IP: 91.189.88.152 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

apt-get updateか、apt-get --fix-missingのどっちかを実行して下さいとある。どう違うのだろうか?

apt-get update
ローカル環境のインデックスファイルの更新を行う。
ローカル環境のインデックスファイルが、サーバ上のインデックスファイルより古い場合、インストールが上手くいかなくなるため、ローカル環境のインデックスファイルを最新にします。

apt-get --fix-missing
ローカル環境のインデックスファイルが、サーバ上のインデックスファイルより古くても、無視して最後まで処理を続けるようです。

恐らく、apt-get updateを選択した方が無難だと判断。

apt-get update

3度目の正直

$ sudo apt install ntpdate

上手くいったようです。

補足:エラーが出てきてても、ntpdateはインストールされていますとのメッセージが表示されていたが、実際はインストールされていませんでした。

10
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
6