* behavior of "# mount /dev"
@ 2011-11-08 8:01 KIMURA Masaru
2011-11-09 0:09 ` Davidlohr Bueso
0 siblings, 1 reply; 5+ messages in thread
From: KIMURA Masaru @ 2011-11-08 8:01 UTC (permalink / raw)
To: util-linux
Hi,
A user continues to mumble about behavior of "# mount /dev" in this list [1].
He said, he did accidentally type
# mount /dev
and "ls /dev" shows only initctl under /dev.
"man mount" said,
If only directory or device is given, for example:
mount /dir
then mount looks for a mountpoint and if not found then for a
device in the /etc/fstab file.
so I guess this is an undocumented behavior.
Naohiro Aota explains that this is expected tmpfs' behavior in kernel. [2]
And I think "just don't do such thing."
But this user still doesn't accept this undocumented mount behavior.
any thought?
[1] http://ml.gentoo.gr.jp/users/201111.month/2194.html
[2] http://ml.gentoo.gr.jp/users/201111.month/2195.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: behavior of "# mount /dev"
2011-11-08 8:01 behavior of "# mount /dev" KIMURA Masaru
@ 2011-11-09 0:09 ` Davidlohr Bueso
2011-11-09 1:47 ` KIMURA Masaru
0 siblings, 1 reply; 5+ messages in thread
From: Davidlohr Bueso @ 2011-11-09 0:09 UTC (permalink / raw)
To: KIMURA Masaru; +Cc: util-linux
On Tue, 2011-11-08 at 17:01 +0900, KIMURA Masaru wrote:
> Hi,
>
> A user continues to mumble about behavior of "# mount /dev" in this list [1].
> He said, he did accidentally type
>
> # mount /dev
This will fail since /dev is immediately mounted and populated at boot
time (by udev among others).
>
> and "ls /dev" shows only initctl under /dev.
>
> "man mount" said,
>
> If only directory or device is given, for example:
>
> mount /dir
>
> then mount looks for a mountpoint and if not found then for a
> device in the /etc/fstab file.
>
> so I guess this is an undocumented behavior.
>
> Naohiro Aota explains that this is expected tmpfs' behavior in kernel. [2]
A whole lot of processes expect /dev/shm to be present; but mount(8)'s
relationship with tmpfs is no different than with any other linux
filesystem.
> And I think "just don't do such thing."
> But this user still doesn't accept this undocumented mount behavior.
>
> any thought?
All in all I'm not sure I follow this problem and Google translate isn't
helping much either. What is very strange is that /dev is not mounted at
startup, and the user should address *that* issue instead of manually
mounting /dev.
>
> [1] http://ml.gentoo.gr.jp/users/201111.month/2194.html
> [2] http://ml.gentoo.gr.jp/users/201111.month/2195.html
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: behavior of "# mount /dev"
2011-11-09 0:09 ` Davidlohr Bueso
@ 2011-11-09 1:47 ` KIMURA Masaru
2011-11-09 9:23 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: KIMURA Masaru @ 2011-11-09 1:47 UTC (permalink / raw)
To: util-linux
> All in all I'm not sure I follow this problem and Google translate isn't
> helping much either.
OK. Now I'm trying to translate Naohiro Aota's explanation below.
-----
Same here on my Gentoo and Ubuntu 11.10.
"# mount /sys" does fail and warn "already mounted" but "# mount /dev" doesn't.
First of all, /dev is mounted on tmpfs which is a filesystem on memory.
And /sys is mounted on sysfs which is another filesystem on memory.
These are different filesystem.
tmpfs provides capabilities to create regular readable/writeable files
and directories.
sysfs provides an interface to read/write to/from kernel parameters.
Considering case of mounting tmpfs and sysfs on multiple mount points,
tmpfs should keep each contents per a mount point.
On the other hands, sysfs should keep identical contents on every mount points.
Based on the above filesystem's difference,
"mount -vvv /sys" shows
mount: fstab path: "/etc/fstab"
mount: mtab path: "/etc/mtab"
mount: lock path: "/etc/mtab~"
mount: temp path: "/etc/mtab.tmp"
mount: UID: 0
mount: eUID: 0
mount: spec: "sysfs"
mount: node: "/sys"
mount: types: "sysfs"
mount: opts: "rw,nosuid,nodev,noexec,relatime"
mount: mount(2) syscall: source: "sysfs", target: "/sys",
filesystemtype: "sysfs", mountflags: 2097166, data: (null)
mount: sysfs already mounted or /sys busy
mount: according to mtab, sysfs is already mounted on /sys
and returns a busy error.
"mount -vvv /dev" shows
mount: fstab path: "/etc/fstab"
mount: mtab path: "/etc/mtab"
mount: lock path: "/etc/mtab~"
mount: temp path: "/etc/mtab.tmp"
mount: UID: 0
mount: eUID: 0
mount: spec: "udev"
mount: node: "/dev"
mount: types: "tmpfs"
mount: opts: "rw,nosuid,relatime,size=10240k,mode=755"
mount: mount(2) syscall: source: "udev", target: "/dev",
filesystemtype: "tmpfs", mountflags: 2097154, data:
size=10240k,mode=755
udev on /dev type tmpfs (rw,nosuid,relatime,size=10240k,mode=755)
and doesn't return a busy error.
Both commands calls mount(2) syscall.
So we guess this difference is in kernel.
Digging kernel code,
mount(2) syscall of "mount /sys" processes in sysfs_mount() in fs/sysfs/mount.c
mount(2) syscall of "mount /dev"processes in shmem_mount() in mm/shmem.c
In sysfs_mount(), it creates a super block like this,
sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info);
sysfs_test_super function checks reusability of the super block.
If a super block is already created, it is reused.
In shmem_mount(), it just call mount_nodev() in fs/super.c.
mount_nodev() creates a super block like this
struct super_block *s = sget(fs_type, NULL, set_anon_super,
NULL);
so this doesn't check reusability of super block unlike sysfs_mout()
because of the second argument is NULL.
This results new super block is always created.
This implementation difference is trivial, we already consider case of
mounting tmpfs and sysfs on multiple mount points.
And we can see "return a busy error" for "mount /sys".
This is do_add_mount() in fs/namespace.c.
/* Refuse the same filesystem on the same mount point */
err = -EBUSY;
if (path->mnt->mnt_sb == newmnt->mnt_sb &&
path->mnt->mnt_root == path->dentry)
goto unlock;
Thus, "mount /dev" always creates new super block and doesn't return a
busy error.
This results, if an user accidentally types "# mount /dev", no busy
error is returned and device files which are managed by udev are
suddenly overlaid new /dev.
Summary:
- "# mount /dev" hides udev managed /dev.
- because it doesn't return a busy error.
- because it uses tmpfs.
- using tmpfs, we are not able to treat this case as error in kernel.
By the way, "umount -l /dev" can unmount the overlaid /dev.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: behavior of "# mount /dev"
2011-11-09 1:47 ` KIMURA Masaru
@ 2011-11-09 9:23 ` Karel Zak
[not found] ` <CAPYQg30QdL8evykx4tfiO+K35ZFTuKOVxY_R08nKz5F=-imsVg@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Karel Zak @ 2011-11-09 9:23 UTC (permalink / raw)
To: KIMURA Masaru; +Cc: util-linux, Miklos Szeredi
On Wed, Nov 09, 2011 at 10:47:45AM +0900, KIMURA Masaru wrote:
>
> Same here on my Gentoo and Ubuntu 11.10.
> "# mount /sys" does fail and warn "already mounted" but "# mount /dev" doesn't.
>
> First of all, /dev is mounted on tmpfs which is a filesystem on memory.
> And /sys is mounted on sysfs which is another filesystem on memory.
Yes, this normal filesystem specific behavior.
[...]
> Summary:
> - "# mount /dev" hides udev managed /dev.
> - because it doesn't return a busy error.
> - because it uses tmpfs.
> - using tmpfs, we are not able to treat this case as error in kernel.
Sure, it's not a bug.
It would be nice to have mount option (VFS flag) to control this behavior,
something like:
# mount -t tmpfs none /dev -o nooverlay
# mount -t tmpfs none /dev --> EBUSY
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* behavior of "# mount /dev"
[not found] ` <CAPYQg30QdL8evykx4tfiO+K35ZFTuKOVxY_R08nKz5F=-imsVg@mail.gmail.com>
@ 2011-11-09 10:32 ` KIMURA Masaru
0 siblings, 0 replies; 5+ messages in thread
From: KIMURA Masaru @ 2011-11-09 10:32 UTC (permalink / raw)
To: util-linux
Oops, gmail remove list address.
Forward for recording the archives.
---------- Forwarded message ----------
From: KIMURA Masaru <hiyuh.root@gmail.com>
Date: 2011/11/9
Subject: Re: behavior of "# mount /dev"
To: Karel Zak <kzak@redhat.com>
>> Summary:
>> - "# mount /dev" hides udev managed /dev.
>> - because it doesn't return a busy error.
>> - because it uses tmpfs.
>> - using tmpfs, we are not able to treat this case as error in kernel.
>
> Sure, it's not a bug.
>
> It would be nice to have mount option (VFS flag) to control this behavior,
> something like:
>
> # mount -t tmpfs none /dev -o nooverlay
>
> # mount -t tmpfs none /dev --> EBUSY
ACK.
Thank you for taking time to check my poor translation.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-11-09 10:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 8:01 behavior of "# mount /dev" KIMURA Masaru
2011-11-09 0:09 ` Davidlohr Bueso
2011-11-09 1:47 ` KIMURA Masaru
2011-11-09 9:23 ` Karel Zak
[not found] ` <CAPYQg30QdL8evykx4tfiO+K35ZFTuKOVxY_R08nKz5F=-imsVg@mail.gmail.com>
2011-11-09 10:32 ` KIMURA Masaru
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).