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 have a filesystem on flash using jffs2. I would like to mount this filesystem read-only, except for a single folder that I would like to be writable.

Is this possible without resorting to something like unionfs and the likes?

share|improve this question
    
Why not just mount it rw but then only allow root to write directories other than the writable one? Root can remount it anyway so you do not gain any safety with two mounts. –  Vality May 12 at 12:06
    
That's an option, but I would like to know if there is a way to do what I describe in my question. –  Grodriguez May 12 at 15:41

2 Answers 2

up vote 3 down vote accepted

You can use a bind mount, although they are a bit finicky about permissions requiring you to mount and then remount the directory to get the correct permissions. The man page of mount suggests:

mount --bind olddir newdir
mount -o remount,rw newdir

however on my Arch system I need to do

mount --bind olddir newdir
mount -o remount,rw olddir newdir

If you only want the directory to be listed in one place you can over mount the directory

mount --bind olddir olddir
mount -o remount,rw olddir olddir
share|improve this answer

Is there a particular reason you must use a single volume?

The thing about read-only filesystems is that you only use them when there is no uncertainty about how big they must be. Let us call this size M. Let us call the size of the storage medium N. You can then create two partitions on that medium, one size M and one size N - M.

This will allow you to mount the read-write volume in its proper location within the overall filesystem, which is mostly read-only.

share|improve this answer
    
The platform is already setup for a single volume, and I just wanted to know if it is possible to mount the FS as RO and then make a specific dir writable, without having to create extra partitions. –  Grodriguez May 12 at 9:44

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.