7

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
3
  • You might be able to do so by editing the /etc/fstab config file. I will see if there is a specific way of doing so.
    – ryekayo
    Aug 9, 2014 at 13:46
  • You can't mount only a folder from a filesystem, unless you're talking about a bind mount. Also what's exactly wrong with mount -o rw,remount? Aug 9, 2014 at 13:54
  • 2
    Do you actually mean a specific mount (with multiple bind mounts, which you don't have right now on your setup), or a specific directory tree? What kernel version do you have? The support for differing options on different bind mounts has changed over time (see unix.stackexchange.com/questions/128336/…, especially the comments). Aug 9, 2014 at 22:22

3 Answers 3

1

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

0

I found a way of editing the /etc/fstab config file so that you can create a bind mount:

/my/real/dir /to/mount/dir <filesystem> rw,bind 0 0

  • none - No options associated with mount point (like quotas)
  • rw - The mount point is read and writeable.
  • bind - The mount point is a bound
  • directory filesystem - ext2,ext3,vfat,etc.
1
0
mount -o rw,remount /foo

will remount /foo mount point rw. If there is a /foo/bar mount point (whether ro or rw), the mount command will likely fail.

If there are /foo/what and /foo/ever directories, those will be rw as well. If your read-only mount point is

/foo
/bar
/baz

then

mount -o rw,remount /foo 

will keep other mount points read only.

4
  • "If there is a /foo/bar mount point (whether ro or rw), the mount command will likely fail." If I understand what you are saying correctly, I don't think this is true. Aug 9, 2014 at 15:22
  • Path to folder: /etc/foo/bar I need remount /bar folder. Should I use mount -o rw,remount /etc?
    – Lexx Luxx
    Aug 9, 2014 at 22:01
  • @triwo Are you sure you aren't saying “mount” when you mean “directory”? Aug 9, 2014 at 22:22
  • I'm closing my question. I can't find helpful info on resolving this issue.
    – Lexx Luxx
    Aug 10, 2014 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .