I have just successfully done

sudo apt-get update
sudo apt-get dist-upgrade

Success meaning they finished and no errors which stopped the process - I did get a warning about something to do with bluetooth - which I don't have, so I continued on

Now when I try to do

sudo apt-get update

It says

Hit:1 http://archive.raspberrypi.org/debian stretch InRelease Hit:2
Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease Reading
package lists...13%

(sometimes it say 12%)

The the raspberry hangs - in that pressing caps-lock no longer changes the capslock light and pressing ctl-c etc does nothing and the only way I can get back is by removing the power

Is there some way I can reset what-ever it is doing or do I have to rebuild my SD card again?

  • I cannot give a definitive answer - the process can take some time, and removing power only exacerbates any problem. You may have corrupt packages. You should ALWAYS make a backup BEFORE upgrading (this applies to all computers not just the Pi). If you can still boot try sudo apt-get clean to empty the cache.
    – Milliways
    Sep 30, 2018 at 4:19
  • Yes the machine boots, the first time. I waited around ten minutes but the percent complete did not change I have also left it overnight and it stayed on 13percent complete
    – Ross
    Sep 30, 2018 at 20:36
  • @Milliways But why should a corrupt package cache cause the entire system to hang completely?
    – PMF
    Jan 30, 2020 at 14:28

2 Answers 2


It seems there is something wrong with your package lists. You can try to rebuild them. The lists are located in /var/lib/apt/lists. With brute force you can delete them but I prefer to do it under control of the package system. For this you can edit all sources.list and comment all repositories in them so you have only empty (without repositories) sources.list. By default you have:

rpi ~$ 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

rpi ~$ 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

Comment the first line in them, save them and update the lists:

rpi ~$ sudo apt update

This will purge the list files in /var/lib/apt/lists. Then remove the comment hashes you have just set and update again.

rpi ~$ sudo apt update

This will download all missing lists from the repositiories.

  • This seemed to work but I still had problems eventually I changed SD card and machine , rebuilt and copied the customisation across. The old one still won’t update although it is a different message.
    – Ross
    Jan 30, 2020 at 20:15
  • @Ross That isn't in the question. So what have you done and what exactly is your problem after that?
    – Ingo
    May 31, 2020 at 18:33

Answering a pretty old post here, but I figured my solution might help others like me who landed on this (and other SE) pages.

I had a similar issue on my Zero 2 W. apt-get update would get a certain percentage through some step, and my SSH session would freeze (along with any other SSH sessions I might have open to the same Raspberry Pi).

I solved it by increasing the swap file size. I had tried many other suggestions from others, eg. disable IPv6, run fsck, and use raspi-config to disable bootup to GUI (since I'm using it headless anyway). I believe that only Disabling startup to GUI was useful - it stopped my SSH sessions locking up completely, allowing me to keep a second SSH session open and monitor resources with htop (although htop itself was still freezing occasionally for up to 30 seconds at a time when the Pi's CPU was really busy with apt-get operations).

htop showed me that system memory was pretty heavily utilised to begin with, then being maxed out by apt-get related processes, spilling over into heavy swapfile use, maxing out the meagre 100 MB which is the default. So I changed the swapfile size from the default 100 MB to 1024 MB, and my problem was resolved. It probably doesn't need to be as high as 1024 MB, I just chose that value so as to make a definitively large change, to see if it solved the issue. I have plenty of spare SD space so I'm going to leave it at 1 GB.

Link for how to change the swap size: https://pimylifeup.com/raspberry-pi-swap-file/

Hope that helps others :)

  • You saved my day! Spent days trying to figure this out. Apt would crash the entire pi on a fresh install of any os version on my Zero 2 W with no error message. Really seems like they should increase the default swap or document this more! Thank you though :)
    – harryisaac
    May 16 at 19:30

Your Answer

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

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