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 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 13
...
DHCPDISCOVER on wlan0 to 255.255.255.255 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>"
Best Answer
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:
mkdir /mnt/ramdisk && mkdir /mnt/ramdisk/var-lib-dhcp
tmpfs /mnt/ramdisk/var-lib-dhcp tmpfs size=10M 0 0
/var/lib/dhcp
to/mnt/ramdisk/var-lib-dhcp