0

I was trying to update my RPI. $sudo apt-get update , and this was my result:

Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

I later triedsudo apt-get update (no $ sign this time), and the result was:

Hit:1 http://archive.raspberrypi.org/debian buster InRelease
Hit:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
Err:1 http://archive.raspberrypi.org/debian buster InRelease
  Splitting up /var/lib/apt/lists/archive.raspberrypi.org_debian_dists_buster_InRelease into data and signature failed
Err:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
  Splitting up /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_InRelease into data and signature failed
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://archive.raspberrypi.org/debian buster InRelease: Splitting up /var/lib/apt/lists/archive.raspberrypi.org_debian_dists_buster_InRelease into data and signature failed
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://raspbian.raspberrypi.org/raspbian buster InRelease: Splitting up /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_InRelease into data and signature failed
W: Failed to fetch http://raspbian.raspberrypi.org/raspbian/dists/buster/InRelease  Splitting up /var/lib/apt/lists/raspbian.raspberrypi.org_raspbian_dists_buster_InRelease into data and signature failed
W: Failed to fetch http://archive.raspberrypi.org/debian/dists/buster/InRelease  Splitting up /var/lib/apt/lists/archive.raspberrypi.org_debian_dists_buster_InRelease into data and signature failed
W: Some index files failed to download. They have been ignored, or old ones used instead.

Then, I did sudo apt update and this is the result:

Get:1 http://archive.raspberrypi.org/debian buster InRelease [32.6 kB]
Err:1 http://archive.raspberrypi.org/debian buster InRelease
  Error writing to output file - write (28: No space left on device) [IP: 46.235.230.122 80]
Get:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Get:2 http://raspbian.raspberrypi.org/raspbian buster InRelease [15.0 kB]
Err:2 http://raspbian.raspberrypi.org/raspbian buster InRelease
  Error writing to output file - write (28: No space left on device) [IP: 93.93.128.193 80]
Reading package lists... Done  
Building dependency tree       
Reading state information... Done
311 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://raspbian.raspberrypi.org/raspbian/dists/buster/InRelease  Error writing to output file - write (28: No space left on device) [IP: 93.93.128.193 80]
W: Failed to fetch http://archive.raspberrypi.org/debian/dists/buster/InRelease  Error writing to output file - write (28: No space left on device) [IP: 46.235.230.122 80]
W: Some index files failed to download. They have been ignored, or old ones used instead.

Is there anything I can do to fix this?

3
  • 2
    "no $ sign this time" ... you should never type the $ sign!! it's just sudo apt-get update ... or alternatively, sudo apt update Jun 18, 2021 at 0:50
  • 1
    that first error message suggests you ran the first command without sudo - that's exactly the error I get when doing so - because as sudo is not an environment variable, running $sudo apt-get update is identical to running apt-get update - in fact, you could do $someRandomStringOfLetters apt-get update and get the same problem - so, the first mystery is solved - please try running sudo apt-get update or sudo apt update again Jun 18, 2021 at 0:55
  • Are you able to run ping -c3 archive.raspberrypi.org and get a working response? It looks like you may have network connectivity problems (now that you've solved your $sudo vs sudo struggles).
    – Dougie
    Mar 15, 2022 at 19:32

3 Answers 3

2

to bring my small stone to the wall I would suggest to try this command:

sudo rm -r /var/lib/apt/lists/*

as you have some sub-folders

3
  • I'm not convinced this would help. Did you actually try to do what your answer suggests? Mar 16, 2022 at 8:43
  • 1
    Yes indeed that's what solved my problem, without the recursive option it was not working.
    – Regpa
    Mar 23, 2022 at 23:02
  • OK then, let me upvote. Mar 25, 2022 at 9:49
0

Unfortunately I don't have a high enough reputation to comment but make sure to include the asterisk (*) in the previous user's answer. The full command should be sudo rm /var/lib/apt/lists/* which will remove all of apt's cached package lists. You should then follow with this command: sudo apt update to see if your problem is resolved.

In addition to this, it looks like you have no disk space remaining on your SD card which may be part of your problem, can you provide the output of df -h to verify this?

Best of luck, Aidan.

2
  • This is the result: Filesystem Size Used Avail Use% Mounted on /dev/root 15G 14G 43M 100% / devtmpfs 1.8G 0 1.8G 0% /dev tmpfs 1.9G 47M 1.8G 3% /dev/shm tmpfs 1.9G 8.6M 1.9G 1% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mmcblk0p1 253M 55M 198M 22% /boot tmpfs 378M 4.0K 378M 1% /run/user/1000 Jun 18, 2021 at 16:25
  • Yes, it looks like your SD card is full, try the sudo rm /var/lib/apt/lists/* solution to see if that will free up sufficient space to run sudo apt update but I don't think you'll have enough space to actually upgrade or install any packages. Jun 18, 2021 at 16:43
0

try this

sudo rm /var/lib/apt/lists/*

in order to remove all the lists and

sudo apt-get update

to download the lists again.

have a nice day

2
  • When I do sudo rm /var/lib/apt/lists/ this is my result: rm: cannot remove '/var/lib/apt/lists/': Is a directory Jun 18, 2021 at 12:39
  • read the answer again ... sudo rm /var/lib/apt/lists/ isn't the same as sudo rm /var/lib/apt/lists/* Jun 19, 2021 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.