1

I have UBIFS device /dev/ubi0_1. The device is root for linux rootfs, mounted on kernel boot as Read-Only.

So i have /dev/ubi0_1 mounted on / as RO.

Later i want to mount /dev/ubi0_1 on /mnt/rootfs as R/W by command:

mount -t ubifs -o rw /dev/ubi0_1 /mnt/rootfs

but it fails with EBUSY.

This command:

mount -t ubifs -o ro /dev/ubi0_1 /mnt/rootfs

is successful.

So it looks like there must be same rights on both mountpoints.

I tried remounting but always rights (RO or RW) propagate automatically between separate mountpoints.

My question is whether there is possibility to mount / as RO and /mnt/rootfs as R/W.

2

I tried remounting but always rights (RO or RW) propagate automatically between separate mountpoints.

If you read through the very long documentation in man mount (or keep searching "read-only"), you will know this is not true when using bind mounts.

To change the status of an individual mount point "(VFS entry)", as opposed to "the original filesystem superblock", you must remount it with the bind option included.

I'm very pleased to report that this worked for me, regardless of whether the original mount point was created using bind.

I suggest the following sequence.

mount -oremount,bind,ro /
mount -oremount,rw /

mount -o bind,rw / /mnt/rootfs

# OR - this should have the same effect as the last command
mount -t ubifs -o rw /dev/ubi0_1 /mnt/rootfs

findmnt will show the overall, effective status - ro or rw - of each mount point individually.

  • @sibislaw cool! Thanks for the question, I wasn't sure how this worked before and it's amazing. Is there an omission in my answer, that you don't want to "click the tick" and mark it as the accepted answer? – sourcejedi Jun 19 '17 at 10:04
  • I clicked. I forgotten to do that ;-) – sibislaw Jun 19 '17 at 10:39
  • @sibislaw thanks, but I only see an upvote. Just beneath the voting arrows, you should also see a tick in the same colour of gray. Care to make that tick turn green and give me another +15 internet points? (It also gives you +2 for accepting an answer ;-) ). – sourcejedi Jun 19 '17 at 11:07
0

It worked for me in form shown below (after boot the / is rw, the dir that i mounted second mountpoint is /layers/rootfs).

mount -o remount,ro /
mount --bind / /layers/rootfs
mount -o remount,rw /layers/rootfs

Citation from man:

      Note that the filesystem mount options will remain the same as those  on  the  original
      mount  point, and cannot be changed by passing the -o option along with --bind/--rbind.
      The mount options can be changed by a separate remount command, for example:

             mount --bind olddir newdir
             mount -o remount,ro newdir
  • If I was looking for this question, I don't think this answer would tell me which commands you tried, that worked. In fact, I think the part of the manpage you quoted is just being confusing. If you started with / being R/W (instead of RO as in your question), and then ran the two commands mount --bind / /mnt/rootfs and mount -oremount,ro /mnt/rootfs, you would also be changing / to RO. – sourcejedi Jun 19 '17 at 9:51
  • I think the version of the manpage on my system fixes this confusion. You can view the updated man page at man7.org/linux/man-pages/man8/mount.8.html – sourcejedi Jun 19 '17 at 10:02
  • I edited my post and i have pasten commands that i used. – sibislaw Jun 19 '17 at 10:42
  • Heh. There's a specific reason I thought this was confusing, and asked you for your commands. My understanding of your third command, is that it also makes / read-write again! You need to include bind as one of the mount options in the third command. – sourcejedi Jun 19 '17 at 11:10
  • @sibislaw welcome , it is better to select the working answer as the good answer . – GAD3R Jun 19 '17 at 11:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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