Linux – How to remount as read-write a specific mount of device

busyboxembeddedlinuxmountpermissions

How to remount as read-write a specific mount of device? (one folder) The file is "Read-only file system", rw-r-r, so it not allow to change permissions. I need to replace that file, then change permissions back to read-only.
I know command

mount -o rw,remount [destination folder]

I know this method is unstable, and may cause complications (every mount will get changed). So I must be sure that this will remount as read-write only a specific destination folder, not every mount of the device. I need do this on running system, not test environment. Embedded linux system. Is that possible?

Path to folder: /etc/foo/bar I need remount /bar folder.

EDIT:

mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
proc on /proc type proc (rw)
ramfs on /var type ramfs (rw)
sysfs on /sys type sysfs (rw)
tmpfs on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/mtdblock4 on /nvram type jffs2 (rw)

output of cat /proc/mounts

cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / squashfs ro 0 0
proc /proc proc rw 0 0
ramfs /var ramfs rw 0 0
sysfs /sys sysfs rw 0 0
tmpfs /dev tmpfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/mtdblock4 /nvram jffs2 rw 0 0

remount command

<root@elocal:/etc/foo/bar> ls -la
total 6
drwxr-xr-x    2 root     0               98 Jan 18  2011 .
drwxrwxr-x    7 root     0              105 Feb 10  2011 ..
-rw-r--r--    1 root     0             1052 Jan 18  2011 file1
-rw-r--r--    1 root     0              270 Jan 18  2011 file2
-rw-r--r--    1 root     0             1088 Jan 18  2011 file3
-rw-r--r--    1 root     0              270 Jan 18  2011 file4

mount -o rw,remount /etc/foo/bar
mount: can't find /etc/foo/bar in /proc/mounts

Best Answer

No; you can not apply mount flags to directories, only the whole filesystem, so you have to make the whole thing rw.

Related Question