Upon attempting to update my Lubuntu (Ubuntu 17.10) system I observed the following error:
$ sudo apt update [sudo] password for user: Hit:1 http://security.ubuntu.com/ubuntu artful-security InRelease Hit:2 http://packages.microsoft.com/repos/vscode stable InRelease Hit:3 http://ca.archive.ubuntu.com/ubuntu artful InRelease Hit:4 https://dl.yarnpkg.com/debian stable InRelease Hit:5 http://ca.archive.ubuntu.com/ubuntu artful-updates InRelease Hit:6 http://ca.archive.ubuntu.com/ubuntu artful-backports InRelease Hit:7 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease Reading package lists... Error! E: Read error - read (5: Input/output error) W: You may want to run apt-get update to correct these problems E: The package cache file is corrupted |
Running sudo apt-get update
or sudo apt clean
didn’t resolve the problem. After doing some research I determined the corrupted files were located in /var/lib/apt/lists/
. From http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/Linux-Filesystem-Hierarchy.html#var:
Holds dynamic data libraries/files like the rpm/dpkg database and game scores. Furthermore, this hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users shouldn’t ever need to modify files in /var/lib to configure a package’s operation. State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. An application (or a group of inter-related applications) use a subdirectory of /var/lib for their data. There is one subdirectory, /var/lib/misc, which is intended for state files that don’t need a subdirectory; the other subdirectories should only be present if the application in question is included in the distribution. /var/lib/’name’ is the location that must be used for all distribution packaging support. Different distributions may use different names, of course.
Clearing everything from the /lists/
seems to have safely resolved the issue for me. Be careful not to delete the lists
directory as I’ve read they’re not recreated by the system.
$ sudo rm -rf /var/lib/apt/lists/* $ sudo apt update |