Every time I create a new AWS EC2 instance with Ubuntu 14.04 (using ami-a182b391
, as found from here) and then immediately run sudo apt-get -y update
, it gives me an error.
Here's the OS info:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty
Here's the failing apt command:
$ sudo apt-get -y update
Ign http://us-west-2.ec2.archive.ubuntu.com trusty InRelease
Ign http://us-west-2.ec2.archive.ubuntu.com trusty-updates InRelease
Hit http://us-west-2.ec2.archive.ubuntu.com trusty Release.gpg
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates Release.gpg
Hit http://us-west-2.ec2.archive.ubuntu.com trusty Release
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates Release
Get:1 http://us-west-2.ec2.archive.ubuntu.com trusty/main Sources [1,064 kB]
Get:2 http://us-west-2.ec2.archive.ubuntu.com trusty/universe Sources [6,399 kB]
Ign http://security.ubuntu.com trusty-security InRelease
Get:3 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:4 http://security.ubuntu.com trusty-security Release [63.5 kB]
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/main amd64 Packages
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/main Translation-en
Hit http://us-west-2.ec2.archive.ubuntu.com trusty/universe Translation-en
Get:5 http://us-west-2.ec2.archive.ubuntu.com trusty-updates/main Sources [196 kB]
Get:6 http://us-west-2.ec2.archive.ubuntu.com trusty-updates/universe Sources [114 kB]
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://us-west-2.ec2.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://us-west-2.ec2.archive.ubuntu.com trusty/main Translation-en_US
Ign http://us-west-2.ec2.archive.ubuntu.com trusty/universe Translation-en_US
Get:7 http://security.ubuntu.com trusty-security/main Sources [80.3 kB]
Get:8 http://security.ubuntu.com trusty-security/universe Sources [21.9 kB]
Get:9 http://security.ubuntu.com trusty-security/main amd64 Packages [267 kB]
Get:10 http://security.ubuntu.com trusty-security/universe amd64 Packages [101 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Fetched 8,308 kB in 4s (1,678 kB/s)
W: Failed to fetch http://us-west-2.ec2.archive.ubuntu.com/ubuntu/dists/trusty-updates/main/source/Sources Hash Sum mismatch
W: Failed to fetch http://us-west-2.ec2.archive.ubuntu.com/ubuntu/dists/trusty-updates/universe/source/Sources Hash Sum mismatch
E: Some index files failed to download. They have been ignored, or old ones used instead.
I've literally done nothing else on the box besides boot it and run this command, and I've tried with multiple instances and it always happens.
I've found a workaround:
$ sudo rm -rf /var/lib/apt/lists/
$ sudo apt-get -y update
Ign http://us-west-2.ec2.archive.ubuntu.com trusty InRelease
Ign http://us-west-2.ec2.archive.ubuntu.com trusty-updates InRelease
Get:1 http://us-west-2.ec2.archive.ubuntu.com trusty Release.gpg [933 B]
Get:2 http://us-west-2.ec2.archive.ubuntu.com trusty-updates Release.gpg [933 B]
...
Get:23 http://security.ubuntu.com trusty-security/main Translation-en [136 kB]
Get:24 http://security.ubuntu.com trusty-security/universe Translation-en [56.8 kB]
Fetched 21.9 MB in 5s (3,724 kB/s)
Reading package lists... Done
But 1) why is this error happening, 2) is this workaround "OK" to do?