When doing ifup wlan0 on a system with / mounted as read-only (embedded computer), I get this error:

Failed to connect to non-global ctrl_ifname: wlan0  error: Read-only file system
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

can't create /var/lib/dhcp/dhclient.wlan0.leases: Read-only file system
Listening on LPF/wlan0/80:1f:02:d3:42:b8
Sending on   LPF/wlan0/80:1f:02:d3:42:b8
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to port 67 interval 7
DHCPDISCOVER on wlan0 to port 67 interval 13
DHCPDISCOVER on wlan0 to port 67 interval 5
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

On the other hand, when doing ifup wlan0 with / mounted as read-write, no problem, an IP is succesfully attributed.

How to make DHCP work on a read-only root filesystem?

# /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "<myssid>"
wpa-psk "<mypasswd>"
  • /var and /tmp must be writable. If you search for "read only root filesystem", there are several guides explaining this. You can either use a separate disk partition for /var, make/var a tmpfs partition, or use a unionfs overlay so the file system appears writable but changes are forgotten on reboot.
    – Mikel
    Jun 16 '15 at 13:45

Create a tmpfs partition in RAM, and then symlink /var/lib/dhcp to a directory in it.

Edit: I'll assume that you can edit your root filesystem before changing it to read-only. So:

  1. Set up a tmpfs mount point with mkdir /mnt/ramdisk && mkdir /mnt/ramdisk/var-lib-dhcp
  2. Add the tmpfs to your fstab with tmpfs /mnt/ramdisk/var-lib-dhcp tmpfs size=10M 0 0
  3. Add a symbolic link from /var/lib/dhcp to /mnt/ramdisk/var-lib-dhcp
  4. Test while file system is read/write
  5. Make file system read-only, test again
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.
    – cuonglm
    Jun 16 '15 at 1:12
  • 2
    How so? It gives a clear technique that solves the problem. Perhaps it doesn't include every detail some people would like, but the OP clearly understands partition creation. (And, if it's details that you miss, you should say so.) Jun 16 '15 at 1:25
  • Thanks @DanielGriscom! I understand the "global" thing, but can you help on how to do it? Should I add tmpfs /tmp/ tmpfs 0 0 in /etc/fstab, and then, where to set up the automatic symlink on boot? (I use systemd) ? Thanks a lot in advance. Last think: can't I simply add this to fstab: tmpfs /var/lib/dhcp tmpfs 0 0 in /etc/fstab ?
    – Basj
    Jun 16 '15 at 6:50
  • (I think I already tried this last thing in my previous comment, and that it didn't work)
    – Basj
    Jun 16 '15 at 7:01
  • Did my suggestion work for you? Jun 18 '15 at 17:56

similar to Daniel Griscom Answer but a little simpler.

you can add

tmpfs /var/lib/dhcp/ tmpfs nodev,nosuid,size=1M,mode=1777 0 0

in /etc/fstab

this creates a temporary file-system in RAM and overwrites the directory as mount-point to this tempfs. (so if you have files there from earlier they are not available)

with this you don't need to manage the symlinks and so on... and 1M for the size should be enough for some embedded board dhcp information. this is also needed if you want to create an AccessPoint with DHCP server (the lease information is stored in the same directory for the server.)

remember to first remount with write access mount -o remount,rw / (as root) - and when you are done with the changes remount write only (mount -o remount,ro /) or reboot..

my original source for this tmpfs configuration string was this short guide on Prepare the microSD for the final application


Assuming that you already have a tmpfs mount point, for instance /run, /var/run or /tmp, a very simple approach is executing,

sudo rm -rf /var/lib/dhcp/


sudo ln -s /run /var/lib/dhcp

The first one will remove your /var/lib/dhcp database directory, the second will create a link to /run. Or you can make the link to /tmp or /var/run.

You will need to remount your filesystem read-write in order to execute the above changes.


I just ran into this problem too, and creating a read-write location for /var/lib/dhcp is not enough.

I had to do the following two things :

trick /sbin/dhclient-script to tell it that / is on a read-only filesystem by adding a commented entry to /etc/fstab :

# The following line is here only to tell dhclient that we are readonly
#/root   /   auto  defaults 0 0

(Note that the "/" must be the second tocken on the line)

And I also had to edit the /etc/dhcp/dhclient.conf configuration file to remove (at least) "domain-name-servers" from the request list (but I removed many more, leaving only those I'm interested in, so I do not know if removing only this one is enough).

If you are interested in receiving domain-name-servers information from the DHCP server, then you may try to link /etc/resolv.conf to a read-write version (either in /run or /var/run or any other tmpfs place, but you'll have to create the file somewhere between the script which monts this tmpfs location and the script which sets up the network), or as a link to a file on a R/W filesystem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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