Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I currently have a busybox based embedded linux system. The filesystem is a readonly mounted jffs2 filesystem. One problem I've run into is that /etc/resolv.conf can't be updated by DHCP.

Is it possible to use a different file than /etc/resolv.conf, say /tmp/resolv.conf (/tmp is mounted as tmpfs).

Or am I being overly paranoid in mounting JFFS2 as read only? The root filesystem is read only because I don't want to wear out the flash.

share|improve this question
    
Where do you have your /var directory pointing too? I've seen a /var/run/resolv.conf with /etc/resolv.conf pointing to it. And from the resolv.conf manpage: On a normally configured system this file should not be necessary. The only name server to be queried will be on the local machine; .... :-) –  ott-- Jan 29 '13 at 16:08
    
/var is a readonly directory, and inside it there is a folder called volatile, which is mounted as tmpfs. There are a bunch of folders that are symlinks to folders inside /var/volatile. /tmp for example is a symlink to /var/volatile/tmp. I think that the filesystem was meant to be mounted as read/write, but I've chosen to mount it readonly. –  Kotte Jan 30 '13 at 9:39
add comment

1 Answer

up vote 5 down vote accepted

You can use a symlink, I just tried this to be sure. Since the stuff in /tmp is impermanent, that means you will have to create the file at boot before dhcpcd runs.

touch /tmp/dhcpcd.resolv.conf
ln -s /tmp/dhcpcd.resolv.conf /etc/resolv.conf

I included the ln bit by way of illustration but note that you don't have to create the symlink every time at boot; just put in your RO system once, and (again) make sure the /tmp file it links to is created before anything tries to access it.

Symlinks share their permissions with the file they link to, and even if the filesystem they are on is RO, as long as the file they link to is not, writing will work.

share|improve this answer
1  
The symlink itself doesn't change, so it can well be kept RO. –  vonbrand Jan 29 '13 at 15:00
    
I did not think that would work if the whole filesystem is RO, but behold, it does. Cheers vonbrand, will edit... –  TAFKA 'goldilocks' Jan 29 '13 at 15:09
    
That is a very elegant solution, thanks :) –  Kotte Jan 29 '13 at 15:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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