FS#26631 - Strange mount --bind behaviour on archiso.

Attached to Project: Arch Linux
Opened by John H. (darkenergy) - Wednesday, 26 October 2011, 09:21 GMT
Last edited by Jan de Groot (JGC) - Wednesday, 26 October 2011, 20:32 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To No-one
Architecture i686
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

I built an archiso image as described in the wiki https://wiki.archlinux.org/index.php/Archiso .
When performing a bind mount, strange things happen.
Firstly, the "mount" command produces information about the bind mount as if it were a real, physical disk.
Secondly, when remounting the bind mount read-only, the "parent" mount is also affected.
See below. I have only included the relevant parts from the output of the "mount" command.


root ~ # pacman -Q linux
linux 3.0.7-1



root ~ # mount
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sys on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=78273,mode=755)
run on /run type tmpfs (rw,nosuid,nodev,relatime,size=10240k,mode=755)
/dev/mapper/arch_root-image on / type ext4 (rw,relatime,user_xattr,acl,barrier=1)
/dev/mapper/arch_lib-modules on /lib/modules type ext4 (rw,relatime,user_xattr,acl,barrier=1)
/dev/mapper/arch_usr-share on /usr/share type ext4 (rw,relatime,user_xattr,acl,barrier=1)
/dev/disk/by-label/ARCH_201110 on /bootmnt type iso9660 (ro,relatime)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,relatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,relatime)



root ~ # mount /dev/sda1 /home/



root ~ # mount
...
/dev/sda1 on /home type ext4 (ro,relatime,user_xattr,acl,barrier=1,data=ordered)



root ~ # mkdir /home/test_1 /home/test_1/sub_1



root ~ # ls /home/test_1/
sub_1



root ~ # mkdir /mnt/bindmount



root ~ # ls /mnt/
bindmount



root ~ # mount --bind /home/test_1/ /mnt/bindmount/



root ~ # mount
...
/dev/sda1 on /home type ext4 (rw,relatime,user_xattr,acl,barrier=1,data=ordered)
/dev/sda1 on /mnt/bindmount type ext4 (rw,relatime,user_xattr,acl,barrier=1,data=ordered)

# ERROR: Here, it should report:
# /home/test_1 on /mnt/bindmount type none (rw,bind)



root ~ # ls /mnt/bindmount/
sub_1



root ~ # mount /mnt/bindmount/ -o remount,ro



root ~ # mount
...
/dev/sda1 on /home type ext4 (ro,relatime,user_xattr,acl,barrier=1,data=ordered)
/dev/sda1 on /mnt/bindmount type ext4 (ro,relatime,user_xattr,acl,barrier=1,data=ordered)
This task depends upon

Closed by  Jan de Groot (JGC)
Wednesday, 26 October 2011, 20:32 GMT
Reason for closing:  Not a bug
Comment by John H. (darkenergy) - Wednesday, 26 October 2011, 09:24 GMT
Note the output of the final "mount" command: Both mounts are now "ro", read-only.
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 26 October 2011, 13:41 GMT
Right. Is the output when using /etc/mtab as symlink to /proc/mounts.
Use findmnt, it will look at /proc/self/mountinfo
Comment by John H. (darkenergy) - Wednesday, 26 October 2011, 13:58 GMT
That's interesting, I didn't know about findmnt.

But it doesn't explain why "mount /mnt/bindmount/ -o remount,ro" causes the "parent" (in my case /home) to be mounted read-only.
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 26 October 2011, 14:02 GMT
because you missed to add --bind or -o bind ;)

If you want a nice explanation see: http://karelzak.blogspot.com/2011/04/bind-mounts-mtab-and-read-only.html
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 26 October 2011, 14:04 GMT
also see the mount(8) manpage when talks about bind mounts and mtab
Comment by John H. (darkenergy) - Wednesday, 26 October 2011, 14:23 GMT
OK, thanks for that link djgera. Understood that. Not a bug then, but a new feature.

Loading...