Skip to content

apt-get and the static IP challenges within Raspbian OS

This is the story of my first experiences with Raspberry PI 2 card computer. Back in March, I bought a new toy, a Raspberry PI 2. I have downloaded the Raspbian OS ISO image, wrote it on the microSD card and the toy was up and running. Raspbian OS Boot

As most probably you already know, the default package manager tool for Debian Linux derived distribution is apt-get. The apt-get command line tool that allows handling packages for new applications installation, updates, uninstall etc. The existence of this tool is one important thing that convinced me to use Linux Mint and Ubuntu instead of Red Hat fork distributions. The Raspbian OS is, also a Debian derived distribution, special design for small card-computer devices such Raspberry PI 2.

As you know the static IP address assignation facilitates easier access to any device (ex. via the SSH protocol) and I prefer to use it. I assigned a fix IP address to my Raspberry device into my router and in addition, I set the network setting to the proper static IP address (editing /etc/network/interfaces).

auto lo
iface lo inet loopback
#iface eth0 inet dhcp

iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

After a device reboot, I started the first update check via apt-get. Having a long experience with Ubuntu and Linux Mint, I had the surprise of getting errors in the moment of “apt-get update” execution.

Err http://raspberrypi.collabora.com wheezy Release.gpg
Temporary failure resolving 'raspberrypi.collabora.com'
Err http://archive.raspberrypi.org wheezy Release.gpg
Temporary failure resolving 'archive.raspberrypi.org'
Err http://mirrordirector.raspbian.org wheezy Release.gpg
Temporary failure resolving 'mirrordirector.raspbian.org'
Reading package lists... Done
W: Failed to fetch http://mirrordirector.raspbian.org/raspbian/dists/wheezy/Release.gpg Temporary failure resolving 'mirrordirector.raspbian.org'
W: Failed to fetch http://raspberrypi.collabora.com/dists/wheezy/Release.gpg Temporary failure resolving 'raspberrypi.collabora.com'
W: Failed to fetch http://archive.raspberrypi.org/debian/dists/wheezy/Release.gpg Temporary failure resolving 'archive.raspberrypi.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.

apt-get cache cleaning provided no improvements. The ping to an explicit IP from Internet was getting an answer but not for domains, so the DNS was not acting as expected. Usually, the DNS settings modification is not needed in case we are using a DHCP server.
I preferred to use the Google’s DNS public DNS service by editing the /etc/resolv.conf file.

nameserver 8.8.8.8
name server 8.8.4.4

But even if I was logged with the root privileges each time I tried to save the /etc/resolv.conf I got “No space left on device” error message. I was surprised to realize that the disk was “100% full” and my microSD card size was less than a half I know (8GB).

pi@raspberrypi ~ $ df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 3036242 3036242 3036242 100% /
/dev/root 3036242 3036242 3036242 100% /

In order to repair such disk space situations, we have to run the raspi-config application, where we have to select the first option Expand Filelsystem.

raspi-config tool

In case you get an error (i got twice), please insist on this option until you’ll get the message “Root partition has been resized“.
After the root partition has been recovered, the proper disk space was displayed. That allowed me the manual define the DNS settings I mentioned earlier within /etc/resolv.conf file.
Off-course you need to restart the network settings. In case you’re connected like me via SSH reboot the toy (sudo reboot). Tring to restart the networking daemon (pi@raspberrypi ~ $ sudo /etc/init.d/networking restart) might make the device unavailable into the network.

With these “improvements” the apt-get application was running perfect with the static IP address and I was able to install whatever official packages I needed.

References:
Raspberry Pi Static IP Address
Raspberry Pi’s “No space left on device” error message

Silviu Ardelean

Software Engineer

More Posts - Website

Follow Me:
TwitterFacebookPinterest

2 thoughts on “apt-get and the static IP challenges within Raspbian OS”

  1. Hi! I am having the same issue with RPi 3 + latest raspbian lite. I have expanded the root filesystem and updated the /etc/resolv.conf with google’s DNS servers, but I get the same error when running sudo apt-get update. I can ping 8.8.8.8 without problems. Any ideeas?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.