On Fri, Jun 24, 2011 at 09:43:32AM +0200, Andreas Schwab wrote:
Karel Zak <kzak(a)redhat.com> writes:
> The 'bind' flag is another way how to achieve that the filesystem is
> mounted on another place. Nothing other.
Pedantic note, there are some extra features usable with MS_BIND,
like MS_UNBINDABLE, MS_REC, etc.
> # mount /dev/sdb1 /mnt/A
> # mount --bind /mnt/A /mnt/B
>
> is the same thing as:
>
> # mount /dev/sdb1 /mnt/A
> # mount /dev/sdb1 /mnt/B
There is a big difference between "mount --bind /mnt/A/B /mnt/B" and
"mount /dev/sdb1 /mnt/B".
Sure. The difference is that the mountpoint is not connected with root
of the filesystem, but with some subdirectory. This information is
stored in /proc/self/mountinfo.
The important is that there is not dependence on the original
mountpoint -- this fact was ignored in mtab, because mtab info about
bind mounts was always based on the paths (e.g. /mnt/A/B) instead on
devices (e.g. /dev/sdb1).
BTW, this is not specific to bind mounts, you can do the same with
btrfs subvolumes.
# mount /dev/sdb1 /mnt/A
# btrfs subvolume create /mnt/A/B
# mount /dev/sdb1 /mnt/B subvol=B
$ df | grep sdb1
/dev/sdb1 1022976 64 892032 1% /mnt/A
/dev/sdb1 1022976 64 892032 1% /mnt/B
$ findmnt /dev/sdb1
TARGET SOURCE FSTYPE OPTIONS
/mnt/A /dev/sdb1 btrfs rw,relatime,ssd
/mnt/B /dev/sdb1[/B] btrfs rw,relatime,ssd
Anyway, let's fix the utils to be usable with Linux VFS independently
on mtab.
Karel
--
Karel Zak <kzak(a)redhat.com>
http://karelzak.blogspot.com