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 use mount --bind to "overlay" a file from one ext4,rw filesystem onto another file in ext4,ro filesystem. For example, /etc/hosts is on a read-only / partition, but I have another partition where /rw/etc/hosts is writable. So when I do

# mount --bind /rw/etc/hosts /etc/hosts

any writes to /etc/hosts will go to /rw/etc/hosts


This worked fine in CentOS 6.3.

# mount -o ro /dev/sdc1 /ro
# mount -o rw /dev/sdc2 /rw
# mount --bind rw/test ro/test
# echo 1 > rw/test
# cat ro/test
1
# echo 2 > ro/test                    # [1]
# cat rw/test
2

But I cannot get it to work in CentOS 6.4 I repeat the steps from above, but I get an error when trying to write to ro/test:

# echo 2 > ro/test                    # [1]
-bash: ro/test: Read-only file system

SELinux is disabled. Any ideas what could cause this to stop working?

CentOS 6.3 kernel: 2.6.32-279.22.1.el6.x86_64
CentOS 6.4 kernel: 2.6.32-358.el6.x86_64 and 2.6.32-358.2.1.el6.x86_64

share|improve this question
    
CentOS 6.3 and CentOS 6.4 have had a variety of different kernel versions. Can you be more specific about the versions of the kernels that do and do not work for you? –  user2472 Apr 12 '13 at 2:43
    
@KenStailey Updated the question with the kernel versions. –  Ivan Apr 12 '13 at 18:11
    
Probably a bug of some kind, but what happens if you specifically mount -o remount,rw your test? –  mikeserv Mar 23 at 20:47
add comment

2 Answers 2

Any ideas what could cause this to stop working?

Probably a bug that was introduced into the kernel along with support for fsfreeze. I opened BZ #951311 to track this.

share|improve this answer
    
I don't have access to the bug you filed, but I will file one myself. It could be related/duplicate. –  Ivan Apr 12 '13 at 18:13
add comment
# mount --bind rw/test ro/test
# echo 1 > rw/test

You can only mount directories.

You cannot use echo to write into a directory.

You probably want

# mount --bind rw ro
share|improve this answer
2  
You can mount --bind files. Please see: unix.stackexchange.com/questions/44373/… –  Ivan Apr 12 '13 at 1:04
1  
Heh, the man page for mount(8) needs some updating. The man page for mount(2) gets it right but mount(8) says newdir and olddir not newnode, etc. –  user2472 Apr 12 '13 at 1:10
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.