Cannot update Raspberry PI (apt-get)
Solution 1
I turned out that the SD-Card was broken. I couldn't even reformat it. Writing zeros with unix's dd
command didn't worked either. So I bought a new SD-Card ;)
Solution 2
All you need to do is type the following command in terminal
sudo rm -r /var/lib/apt/lists/*
after that run the following command
sudo apt-get clean && sudo apt-get update
you should find this will fix any packaging issue and merge list errors
Rose Nettoyeur
Updated on September 18, 2022Comments
-
Rose Nettoyeur over 1 year
I cannot update my Raspberry PI (Raspberry PI 1 Model B with Raspbian Stretch) anymore.
sudo apt-get update
tells me that there are some problems with package files. I don't know much about apt-get and how it works so I cannot give more information.Here is what I tried before:
pi@raspberrypi:~ $ sudo apt-get update Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB] Get:2 http://mirrordirector.raspbian.org/raspbian buster InRelease [15.0 kB] Get:3 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB] Get:4 http://mirrordirector.raspbian.org/raspbian buster/main armhf Packages [13.0 MB] Get:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB] Get:6 http://mirrordirector.raspbian.org/raspbian buster/contrib armhf Packages [59.1 kB] Get:7 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB] Get:8 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB] Get:9 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB] Fetched 25.1 MB in 1min 6s (376 kB/s) Reading package lists... Error! E: Encountered a section with no Package: header E: Problem with MergeList /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_non-free_binary-armhf_Packages E: The package lists or status file could not be parsed or opened. pi@raspberrypi:~ $ sudo rm /var/lib/apt/lists/* -vf removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_stretch_InRelease' removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_stretch_main_binary-armhf_Packages' removed '/var/lib/apt/lists/archive.raspberrypi.org_debian_dists_stretch_ui_binary-armhf_Packages' removed '/var/lib/apt/lists/lock' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_contrib_binary-armhf_Packages' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_InRelease' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_main_binary-armhf_Packages' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_non-free_binary-armhf_Packages' removed '/var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_rpi_binary-armhf_Packages' rm: cannot remove '/var/lib/apt/lists/partial': Is a directory removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_contrib_binary-armhf_Packages' removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_InRelease' removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_main_binary-armhf_Packages' removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_non-free_binary-armhf_Packages' removed '/var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_stretch_rpi_binary-armhf_Packages' pi@raspberrypi:~ $ sudo apt-get update Get:1 http://mirrordirector.raspbian.org/raspbian buster InRelease [15.0 kB] Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB] Get:3 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB] Get:4 http://mirrordirector.raspbian.org/raspbian buster/main armhf Packages [13.0 MB] Get:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB] Get:6 http://mirrordirector.raspbian.org/raspbian buster/contrib armhf Packages [59.1 kB] Get:7 http://mirrordirector.raspbian.org/raspbian buster/non-free armhf Packages [103 kB] Get:8 http://mirrordirector.raspbian.org/raspbian buster/rpi armhf Packages [1,360 B] Get:9 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB] Get:10 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB] Get:11 http://raspbian.raspberrypi.org/raspbian stretch/contrib armhf Packages [56.9 kB] Get:12 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB] Get:13 http://raspbian.raspberrypi.org/raspbian stretch/rpi armhf Packages [1,360 B] Fetched 25.3 MB in 1min 5s (384 kB/s) Reading package lists... Error! E: Unable to parse package file /var/lib/dpkg/status (1) W: You may want to run apt-get update to correct these problems E: The package cache file is corrupted
Of course I tried running
sudo apt-get update
again but then I get the same error.Here is some additional info about my source lists. Maybe this helps:
pi@raspberrypi:~ $ sudo cat /etc/apt/sources.list 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 pi@raspberrypi:~ $ sudo ls /etc/apt/ apt.conf.d listchanges.conf preferences.d sources.list sources.list.d trusted.gpg trusted.gpg.d pi@raspberrypi:~ $ sudo ls /etc/apt/sources.list.d/ 10-buster.list raspi.list pi@raspberrypi:~ $ sudo cat /etc/apt/sources.list.d/10-buster.list deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi pi@raspberrypi:~ $ sudo cat /etc/apt/sources.list.d/raspi.list deb http://archive.raspberrypi.org/debian/ stretch main ui # Uncomment line below then 'apt-get update' to enable 'apt-get source' #deb-src http://archive.raspberrypi.org/debian/ stretch main ui
UPDATE: I did what comment #2 suggested. Unfortunately that did not help :( Here is the output:
pi@raspberrypi:~ $ cd /var/lib/apt pi@raspberrypi:/var/lib/apt $ sudo mv lists lists.old pi@raspberrypi:/var/lib/apt $ sudo mkdir -p /var/lib/apt/lists/partial pi@raspberrypi:/var/lib/apt $ sudo apt-get update Get:1 http://mirrordirector.raspbian.org/raspbian buster InRelease [15.0 kB] Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB] Get:3 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB] Get:4 http://mirrordirector.raspbian.org/raspbian buster/main armhf Packages [13.0 MB] Get:5 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages [11.7 MB] Get:6 http://mirrordirector.raspbian.org/raspbian buster/contrib armhf Packages [59.1 kB] Get:7 http://mirrordirector.raspbian.org/raspbian buster/non-free armhf Packages [103 kB] Get:8 http://mirrordirector.raspbian.org/raspbian buster/rpi armhf Packages [1,360 B] Get:9 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB] Get:10 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB] Err:10 http://archive.raspberrypi.org/debian stretch/ui armhf Packages Hash Sum mismatch Hashes of expected file: - Filesize:44957 [weak] - SHA256:8cae70e2e6b9edf4dcdaa5698f0b19478f9de69e29c9600308f46cf3e0045e2e - SHA1:ea81522b950027496c2ced0eb2ff6ede2e75f897 [weak] - MD5Sum:ae6ca9fe1a5cca877cae33de122ababe [weak] Hashes of received file: - SHA256:bc3e0c2522623b50e36251cea08e80cd876aae57b83c83aab83183b54155311c - SHA1:14b504b069e7d4404c8cb41eebd73c2702918116 [weak] - MD5Sum:d1929e4454bbbb207ae70e00d0fd54cd [weak] - Filesize:44949 [weak] Last modification reported: Fri, 26 Apr 2019 20:49:31 +0000 Release file created at: Mon, 29 Apr 2019 12:36:11 +0000 Get:11 http://raspbian.raspberrypi.org/raspbian stretch/contrib armhf Packages [56.9 kB] Get:12 http://raspbian.raspberrypi.org/raspbian stretch/non-free armhf Packages [95.5 kB] Get:13 http://raspbian.raspberrypi.org/raspbian stretch/rpi armhf Packages [1,360 B] Fetched 25.3 MB in 1min 3s (401 kB/s) Reading package lists... Done E: Failed to fetch http://archive.raspberrypi.org/debian/dists/stretch/ui/binary-armhf/Packages.gz Hash Sum mismatch Hashes of expected file: - Filesize:44957 [weak] - SHA256:8cae70e2e6b9edf4dcdaa5698f0b19478f9de69e29c9600308f46cf3e0045e2e - SHA1:ea81522b950027496c2ced0eb2ff6ede2e75f897 [weak] - MD5Sum:ae6ca9fe1a5cca877cae33de122ababe [weak] Hashes of received file: - SHA256:bc3e0c2522623b50e36251cea08e80cd876aae57b83c83aab83183b54155311c - SHA1:14b504b069e7d4404c8cb41eebd73c2702918116 [weak] - MD5Sum:d1929e4454bbbb207ae70e00d0fd54cd [weak] - Filesize:44949 [weak] Last modification reported: Fri, 26 Apr 2019 20:49:31 +0000 Release file created at: Mon, 29 Apr 2019 12:36:11 +0000 E: Some index files failed to download. They have been ignored, or old ones used instead. pi@raspberrypi:/var/lib/apt $ ls -al /var/lib/dpkg/status* -rw-r--r-- 1 root root 535604 Feb 24 10:04 /var/lib/dpkg/status -rw-r--r-- 1 root root 536580 Feb 24 10:00 /var/lib/dpkg/status-old pi@raspberrypi:/var/lib/apt $ ls -al /var/backups/dpkg.status.* -rw-r--r-- 1 root root 535604 Feb 24 10:04 /var/backups/dpkg.status.0 -rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.1.gz -rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.2.gz -rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.3.gz -rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.4.gz -rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.5.gz -rw-r--r-- 1 root root 161528 Feb 24 10:04 /var/backups/dpkg.status.6.gz pi@raspberrypi:/var/lib/apt $ sudo apt-get update Hit:1 http://mirrordirector.raspbian.org/raspbian buster InRelease Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease Get:3 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB] Get:4 http://archive.raspberrypi.org/debian stretch/main armhf Packages [223 kB] Get:5 http://archive.raspberrypi.org/debian stretch/ui armhf Packages [45.0 kB] Fetched 293 kB in 5s (52.6 kB/s) Reading package lists... Error! E: Encountered a section with no Package: header E: Problem with MergeList /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_main_binary-armhf_Packages E: The package lists or status file could not be parsed or opened. pi@raspberrypi:/var/lib/apt $ sudo apt-get upgrade Reading package lists... Error! E: Encountered a section with no Package: header E: Problem with MergeList /var/lib/apt/lists/mirrordirector.raspbian.org_raspbian_dists_buster_main_binary-armhf_Packages E: The package lists or status file could not be parsed or opened. pi@raspberrypi:/var/lib/apt $
-
darrend about 5 yearslooks like your
dpkg-status
file got corrupted. Try once more with the clean of the lists directory, but instead ofsudo rm /var/lib/apt/lists/* -vf
dosudo mv /var/lib/apt/lists /var/lib/apt/lists.old && sudo mkdir -p /var/lib/apt/lists/partial
then try theapt-get update
again -
darrend about 5 yearsif the above fails, update your question to show the output from the following 2 commands:
ls -al /var/lib/dpkg/status*
andls -al /var/backups/dpkg.status.*
-
Comar about 5 yearsplease also read this: unix.stackexchange.com/questions/161866/… in case you've deleted your
/var/lib/dpkg/status
file -
Rose Nettoyeur almost 5 yearsI updated the question
-