[opensuse-kernel] Problems with bind mount on OpenSUSE 11.4
Hi, bind mounts seem not to work as expected on OpenSUSE 11.4. E.g: $ mount /home /mnt -o bind $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) $ mount | grep sda1 /dev/sda1 on / type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) mount shows me the for both / and /mnt /dev/sda1 as device. The expected output is: /home on /mnt type none (rw,bind) The read-only bind mount also does not work. $ mount -o bind,ro /home /mnt mount: warning: /mnt seems to be mounted read-write. $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) I can reproduce this on OpenSUSE 11.4 using kernel-desktop-2.6.37.1-1.2.2.i586, kernel-vanilla-2.6.37.1-1.2.2.i586 and kernel-vanilla-2.6.37.3-16.1.i586 (from tumbleweed repo) But, on a CentOS 5.5 box with a hand compiled 2.6.37.3 kernel everything works as expected. Now I'm confused, is this a OpenSUSE or a kernel issue? Any ideas? -- Thanks, //richard -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
On Sun, Mar 13, 2011 at 6:03 PM, richard -rw- weinberger <richard.weinberger@gmail.com> wrote:
Hi,
bind mounts seem not to work as expected on OpenSUSE 11.4.
E.g: $ mount /home /mnt -o bind $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) $ mount | grep sda1 /dev/sda1 on / type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered)
mount shows me the for both / and /mnt /dev/sda1 as device.
The expected output is: /home on /mnt type none (rw,bind)
Update: On 11.4 /etc/mtab is a symlink to /proc/self/mounts. This causes the first issue.
The read-only bind mount also does not work. $ mount -o bind,ro /home /mnt mount: warning: /mnt seems to be mounted read-write. $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered)
I can reproduce this on OpenSUSE 11.4 using kernel-desktop-2.6.37.1-1.2.2.i586, kernel-vanilla-2.6.37.1-1.2.2.i586 and kernel-vanilla-2.6.37.3-16.1.i586 (from tumbleweed repo)
But, on a CentOS 5.5 box with a hand compiled 2.6.37.3 kernel everything works as expected.
Now I'm confused, is this a OpenSUSE or a kernel issue? Any ideas?
-- Thanks, //richard
-- Thanks, //richard -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
On Sun, Mar 13, 2011 at 06:03:20PM +0100, richard -rw- weinberger wrote:
Hi,
bind mounts seem not to work as expected on OpenSUSE 11.4.
Yes, it behaves slightly different as a consequence of making /etc/mtab a symlink to /proc/self/mounts. It's documented in mount(8): --------- Note that behavior of the remount operation depends on the /etc/mtab file. The first command stores the 'bind' flag to the /etc/mtab file and the second command reads the flag from the file. If you have a system without the /etc/mtab file or if you explicitly define source and target for the remount command (then mount(8) does not read /etc/mtab), then you have to use bind flag (or option) for the remount command too. For example: mount --bind olddir newdir mount -o remount,ro,bind olddir newdir ---------
E.g: $ mount /home /mnt -o bind $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) $ mount | grep sda1 /dev/sda1 on / type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered)
mount shows me the for both / and /mnt /dev/sda1 as device.
Information about bind mounts is missing in /proc/self/mounts and thus also in /etc/mtab. AFAIK this should and will be resolved with new util-linux, which will store the bind information into /dev/.mount/utab or something similar.
The expected output is: /home on /mnt type none (rw,bind)
The read-only bind mount also does not work. $ mount -o bind,ro /home /mnt mount: warning: /mnt seems to be mounted read-write. $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered)
Try this: mount -o bind /home /mnt mount -o remount,ro,bind /mnt
I can reproduce this on OpenSUSE 11.4 using kernel-desktop-2.6.37.1-1.2.2.i586, kernel-vanilla-2.6.37.1-1.2.2.i586 and kernel-vanilla-2.6.37.3-16.1.i586 (from tumbleweed repo)
But, on a CentOS 5.5 box with a hand compiled 2.6.37.3 kernel everything works as expected.
Now I'm confused, is this a OpenSUSE or a kernel issue?
util-linux (known) issue. HTH, Petr -- Petr Uzel IRC: ptr_uzl @ freenode
On Wed, Mar 16, 2011 at 10:54 AM, Petr Uzel <petr.uzel@suse.cz> wrote:
On Sun, Mar 13, 2011 at 06:03:20PM +0100, richard -rw- weinberger wrote:
Hi,
bind mounts seem not to work as expected on OpenSUSE 11.4.
Yes, it behaves slightly different as a consequence of making /etc/mtab a symlink to /proc/self/mounts.
It's documented in mount(8): --------- Note that behavior of the remount operation depends on the /etc/mtab file. The first command stores the 'bind' flag to the /etc/mtab file and the second command reads the flag from the file. If you have a system without the /etc/mtab file or if you explicitly define source and target for the remount command (then mount(8) does not read /etc/mtab), then you have to use bind flag (or option) for the remount command too. For example:
mount --bind olddir newdir mount -o remount,ro,bind olddir newdir ---------
E.g: $ mount /home /mnt -o bind $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) $ mount | grep sda1 /dev/sda1 on / type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered) /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered)
mount shows me the for both / and /mnt /dev/sda1 as device.
Information about bind mounts is missing in /proc/self/mounts and thus also in /etc/mtab. AFAIK this should and will be resolved with new util-linux, which will store the bind information into /dev/.mount/utab or something similar.
Will OpenSUSE 11.4 get an update to this new util-linux package?
The expected output is: /home on /mnt type none (rw,bind)
The read-only bind mount also does not work. $ mount -o bind,ro /home /mnt mount: warning: /mnt seems to be mounted read-write. $ mount | grep mnt /dev/sda1 on /mnt type ext3 (rw,relatime,errors=continue,user_xattr,acl,commit=600,barrier=0,data=ordered)
Try this: mount -o bind /home /mnt mount -o remount,ro,bind /mnt
This works fine. :-)
I can reproduce this on OpenSUSE 11.4 using kernel-desktop-2.6.37.1-1.2.2.i586, kernel-vanilla-2.6.37.1-1.2.2.i586 and kernel-vanilla-2.6.37.3-16.1.i586 (from tumbleweed repo)
But, on a CentOS 5.5 box with a hand compiled 2.6.37.3 kernel everything works as expected.
Now I'm confused, is this a OpenSUSE or a kernel issue?
util-linux (known) issue.
Ok.
HTH,
Petr
-- Petr Uzel IRC: ptr_uzl @ freenode
-- Thanks, //richard -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
On Wed, Mar 16, 2011 at 11:37:50AM +0100, richard -rw- weinberger wrote:
On Wed, Mar 16, 2011 at 10:54 AM, Petr Uzel <petr.uzel@suse.cz> wrote:
On Sun, Mar 13, 2011 at 06:03:20PM +0100, richard -rw- weinberger wrote:
Hi,
bind mounts seem not to work as expected on OpenSUSE 11.4.
Yes, it behaves slightly different as a consequence of making /etc/mtab a symlink to /proc/self/mounts.
---- snip ----
Information about bind mounts is missing in /proc/self/mounts and thus also in /etc/mtab. AFAIK this should and will be resolved with new util-linux, which will store the bind information into /dev/.mount/utab or something similar.
Will OpenSUSE 11.4 get an update to this new util-linux package?
Most likely no, sorry. OTOH, util-linux package in tumbleweed follows latest upstream releases, so you might want to install that package (for now, it does not make any difference as this issue hasn't been addressed in upstream yet).
Try this: mount -o bind /home /mnt mount -o remount,ro,bind /mnt
This works fine. :-)
Good :) Best regards, Petr -- Petr Uzel IRC: ptr_uzl @ freenode
On Wed, Mar 16, 2011 at 11:47 AM, Petr Uzel <petr.uzel@suse.cz> wrote:
On Wed, Mar 16, 2011 at 11:37:50AM +0100, richard -rw- weinberger wrote:
On Wed, Mar 16, 2011 at 10:54 AM, Petr Uzel <petr.uzel@suse.cz> wrote:
On Sun, Mar 13, 2011 at 06:03:20PM +0100, richard -rw- weinberger wrote:
Hi,
bind mounts seem not to work as expected on OpenSUSE 11.4.
Yes, it behaves slightly different as a consequence of making /etc/mtab a symlink to /proc/self/mounts.
---- snip ----
Information about bind mounts is missing in /proc/self/mounts and thus also in /etc/mtab. AFAIK this should and will be resolved with new util-linux, which will store the bind information into /dev/.mount/utab or something similar.
Will OpenSUSE 11.4 get an update to this new util-linux package?
Most likely no, sorry. OTOH, util-linux package in tumbleweed follows latest upstream releases, so you might want to install that package (for now, it does not make any difference as this issue hasn't been addressed in upstream yet).
Very sad. IMHO the release notes should tell about this issue.
Try this: mount -o bind /home /mnt mount -o remount,ro,bind /mnt
This works fine. :-)
Good :)
Can you please explain me why this works? Is this an util-linux issue too?
Best regards,
Petr
-- Petr Uzel IRC: ptr_uzl @ freenode
-- Thanks, //richard -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
On Wed, Mar 16, 2011 at 11:57:01AM +0100, richard -rw- weinberger wrote:
On Wed, Mar 16, 2011 at 11:47 AM, Petr Uzel <petr.uzel@suse.cz> wrote:
Try this: mount -o bind /home /mnt mount -o remount,ro,bind /mnt
Can you please explain me why this works?
Simple 'mount -o bind,ro /olddir /newdir' just does not work, as explained in mount(8) manpage: 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, ... In the past, this seemed to work, but actually the situation was much worse than it is now. What actually happened with earlier versions of util-linux (mount), was that the kernel did bind mount, but silently ignored the RO flag, so the bind mount was in fact RW. What's worse, mount did not recognize this and reported the mount as RO. Here's example on one of the older systems: # mount -o bind,ro /proc/proc_bind # mount | grep proc_bind /proc on /proc_bind type none (ro,bind) OK, mount shows it as RO ... # cat /etc/mtab | grep proc_bind /proc /proc_bind none ro,bind 0 0 ... Because it reads the info from /etc/mtab, but ... # cat /proc/self/mounts | grep proc_bind proc /proc_bind proc rw,relatime 0 0 ... but it is actually RW! So util-linux/mount(8) was fixed and now recognizes this situation and reports the RW bind mount (when the user believes it is RO). So you have to use additional 'mount -o remount,ro' to make it really read only. More info: http://lwn.net/Articles/281157/ BTW this is one example of possible discrepancies between /etc/mtab and /proc/self/mounts and one of the reasons why we made /etc/mtab a symlink to /proc/self/mounts. The reason why you have to use bind flag with the remount command is explained in my previous mail and man mount, I believe. Does this help? BR, Petr -- Petr Uzel IRC: ptr_uzl @ freenode
On Wed, Mar 16, 2011 at 3:19 PM, Petr Uzel <petr.uzel@suse.cz> wrote:
On Wed, Mar 16, 2011 at 11:57:01AM +0100, richard -rw- weinberger wrote:
On Wed, Mar 16, 2011 at 11:47 AM, Petr Uzel <petr.uzel@suse.cz> wrote:
Try this: mount -o bind /home /mnt mount -o remount,ro,bind /mnt
Can you please explain me why this works?
Simple 'mount -o bind,ro /olddir /newdir' just does not work, as explained in mount(8) manpage:
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, ...
In the past, this seemed to work, but actually the situation was much worse than it is now. What actually happened with earlier versions of util-linux (mount), was that the kernel did bind mount, but silently ignored the RO flag, so the bind mount was in fact RW. What's worse, mount did not recognize this and reported the mount as RO.
Here's example on one of the older systems:
# mount -o bind,ro /proc/proc_bind # mount | grep proc_bind /proc on /proc_bind type none (ro,bind)
OK, mount shows it as RO ...
# cat /etc/mtab | grep proc_bind /proc /proc_bind none ro,bind 0 0
... Because it reads the info from /etc/mtab, but ...
# cat /proc/self/mounts | grep proc_bind proc /proc_bind proc rw,relatime 0 0
... but it is actually RW!
So util-linux/mount(8) was fixed and now recognizes this situation and reports the RW bind mount (when the user believes it is RO).
So you have to use additional 'mount -o remount,ro' to make it really read only.
More info: http://lwn.net/Articles/281157/
BTW this is one example of possible discrepancies between /etc/mtab and /proc/self/mounts and one of the reasons why we made /etc/mtab a symlink to /proc/self/mounts.
The reason why you have to use bind flag with the remount command is explained in my previous mail and man mount, I believe.
Does this help?
Yes. Thanks a lot!
BR,
Petr
-- Petr Uzel IRC: ptr_uzl @ freenode
-- Thanks, //richard -- To unsubscribe, e-mail: opensuse-kernel+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-kernel+help@opensuse.org
participants (2)
-
Petr Uzel
-
richard -rw- weinberger