Sunday, August 17, 2014

Fixing up Raspberry Pi with apt-get update woes.

Greetings, weary tech[no] traveler!

Lately, I've been having some trouble updating the software on my Raspberry Pi (running Raspbian) via 'apt-get update'.  Every time I would run:

sudo apt-get update

I would get the following output:

Hit http://archive.raspberrypi.org wheezy Release.gpg
Hit http://mirrordirector.raspbian.org wheezy Release.gpg
Hit http://archive.raspberrypi.org wheezy Release
Hit http://mirrordirector.raspbian.org wheezy Release
Hit http://archive.raspberrypi.org wheezy/main armhf Packages        
Ign http://archive.raspberrypi.org wheezy/main Translation-en       
Hit http://raspberrypi.collabora.com wheezy Release.gpg             
Hit http://raspberrypi.collabora.com wheezy Release
Hit http://raspberrypi.collabora.com wheezy/rpi armhf Packages
Ign http://raspberrypi.collabora.com wheezy/rpi Translation-en
Get:1 http://mirrordirector.raspbian.org wheezy/main armhf Packages [6891 kB]
Hit http://mirrordirector.raspbian.org wheezy/contrib armhf Packages               
Hit http://mirrordirector.raspbian.org wheezy/non-free armhf Packages                                                                                                                                     
Hit http://mirrordirector.raspbian.org wheezy/rpi armhf Packages                                                                                                                                          
Ign http://mirrordirector.raspbian.org wheezy/contrib Translation-en                                                                                                                                      
Ign http://mirrordirector.raspbian.org wheezy/main Translation-en                                                                                                                                         
Ign http://mirrordirector.raspbian.org wheezy/non-free Translation-en                                                                                                                                     
Ign http://mirrordirector.raspbian.org wheezy/rpi Translation-en                                                                                                                                          
100% [1 Packages xz 0 B]

And it would just hang there.  Until the SSH connection would time out.

It is important for me to successfully run updates on my Raspberry Pi.  If you're running something like Apache or a MySQL server you've got to be able to patch them.  Also, I have a healthy case of paranoia when it comes to software updates and information security.  Anyway...

It turned out I was running an older version of the Raspberry Pi firmware, which was impeding my ability to successfully run apt-get update && apt-get upgrade.

I'm sure I'm not the only one who had this problem.  Now that I've fixed this problem for myself, I thought I'd show you how to fix it yourself.

  1. First, make sure your Raspberry Pi has a solid connection to the internet. 
  2. Log in.
  3. Update the Raspberry Pi firmware:

    sudo rpi-update

    If rpi-update terminates with the following (or similar) error:
     *** Relaunching after update
     *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
     *** We're running for the first time
     *** Backing up files (this will take a few minutes)
     *** Backing up firmware
     *** Backing up modules 3.12.20+
    cp: cannot stat `//lib/modules/3.12.20+': No such file or directory

    Then create a directory called in 3.12.20+ in the directory /lib/modules/:

    sudo mkdir /lib/modules/3.12.20+and then run sudo rpi-update again.
  4. This will take about 10 minutes, so go for a walk, grab a beer, etc.
  5. If no errors appeared, your firmware was successfully updated.  Reboot your Raspberry Pi to activate the new firmware:

    sudo reboot
  6. Once the Raspberry Pi has rebooted, log in, and run your updates:

    sudo apt-get update && sudo apt-get upgrade

No comments: