Preventing RDNSSD from Ruining the SD Card

So I have a Raspberry Pi running in the Freifunk Bremen network. It has a dynamic IPv6 address; and since there are currently five active gateway servers on this network which also act as DNS servers, I wanted to get these DNS server addresses dynamically as well.

This can be done with the rdnssd daemon: it listens for IPv6 Neighbour Discovery Protocol packets (in particular Router Advertisements) and extracts the DNS server addresses from them. The addresses are then written to the /etc/resolv.conf file so that they are used as normal DNS servers by the system.

However after setting this up I noticed that the green LED on my Raspi was lighting up every few seconds, indicating “disk” activity. Of course with a Raspi there is no magnetic hard disk but rather a MicroSD card which contains the file system; and since these cards can only tolerate a limited number of write cycles, the frequent LED blinks were worrying.

The cause of the write accesses was that the /etc/resolv.conf file was rewritten every few seconds. IPv6 RA packets are received quite frequently here (about 100 packets per minute!); and each time the ordering of DNS servers is updated to prefer the server that was received most recently.

Updating the /etc/resolv.conf file is done by the resolvconf tool (actually the openresolv tool, if you look under the hood). It takes name server addresses from various sources (like DHCP client, VPN connections, RDNSSD, and static network configuration) and combines those into a single resolv.conf file. So whenever RDNSSD wanted to reorder the DNS servers it had received, resolvconf rewrote the /etc/resolv.conf file.

To prevent the resolvconf tool from frequently writing to SD card, I took the following steps:

  • make /etc/resolv.conf a symbolic link to /var/run/resolv.conf.
    /var/run resides on a ramdisk so data written there does not touch the actual SD card. This also means that the /var/run/resolv.conf file will be lost during reboot; but the resolvconf tool will recreate it during boot.
  • disable the unbound_conf=/var/cache/unbound/resolvconf_resolvers.conf line in /etc/resolvconf.conf. This line was causing the resolvconf tool to also update the /var/cache/unbound/resolvconf_resolvers.conf file every few seconds (which was unnecessary in my case, since I don’t have an Unbound DNS Server installed on the Raspi); and since /var/cache is stored on the SD card, this caused an actual write access to the card.

After making these two changes, the green LED once again remains dark, and cat /etc/resolv.conf shows that the IPv6 name servers merrily change every few seconds.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: