Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Oct 2012 18:20:18 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        Alexander Yerenkow <yerenkow@gmail.com>
Cc:        freebsd-current <freebsd-current@FreeBSD.org>
Subject:   Re: A little question about safe mode
Message-ID:  <50801E32.80309@FreeBSD.org>
In-Reply-To: <CAPJF9wm9DxZxr5GDCxkoedG%2BdppJsLEN=zYmEEXByaATM4pE3A@mail.gmail.com>
References:  <CAPJF9wm-dvUwgQzZzijakD=FBM9HTBQ%2BF4jC510KX%2BUOG-SfgA@mail.gmail.com> <507FB6C7.50402@FreeBSD.org> <CAPJF9wku0MiuLv=s2NG7F3zpKFq94_NcUZ_F9TXhBssWE7bFeg@mail.gmail.com> <507FEC7F.4030306@FreeBSD.org> <CAPJF9wm9DxZxr5GDCxkoedG%2BdppJsLEN=zYmEEXByaATM4pE3A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
on 18/10/2012 16:50 Alexander Yerenkow said the following:
> 
> 
> 2012/10/18 Andriy Gapon <avg@freebsd.org <mailto:avg@freebsd.org>>
> 
>     on 18/10/2012 12:11 Alexander Yerenkow said the following:
>     > 2012/10/18 Andriy Gapon <avg@freebsd.org <mailto:avg@freebsd.org>
>     <mailto:avg@freebsd.org <mailto:avg@freebsd.org>>>
>     >
>     >
>     >     First, I see "safe mode" mentioned in the subject, but nowhere in the
>     body of
>     >     the message?  So, what's up with the safe mode? :-)
>     >
>     >
>     > The single mode of course, which is forced :) Mistype, sorry.
> 
>     I missed this part - what do you mean by "forced"?
>     You can send the screenshots (as links).
> 
> 
> Here are screenshots, step-by step.
> http://imageshack.us/photo/my-images/407/sc1y.png/
> http://imageshack.us/photo/my-images/90/sc2xs.png/
> http://imageshack.us/photo/my-images/713/sc3y.png/
> http://imageshack.us/photo/my-images/213/sc4h.png/

I am curious would happen if you tried "mount -uw /" again...
Note how mount(8) with no options first reported
ada0s1a on / (...)
and later
/dev/ada0s1a on / (...)

I think that the above information also explains why rc.d/root failed with the
following diagnostic:
mount: ada0s1a: No such file or directory
Mounting root filesystem rw failed, startup aborted

Here is a simple explanation without going into details.
When the kernel is about to mount a root filesystem, it first mounts devfs at /
and also creates /dev symlink to /.  Because of this, both device names with /dev/
"prefix" and device names without it can be correctly resolved without any
additional magic.
E.g., at mountroot prompt you can specify either ufs:ada0s1a or ufs:/dev/ada0s1a
and both should work.

The problem, is that the device name will get recorded in the mount structures
verbatim.  Later, after the kernel has mounted the real root filesystem it also
moves devfs to its proper /dev place.
So only full paths correctly work from that point on.

I am not sure if mount(8) is supposed to prepend "/dev/" if I use a command line
like this:
mount ada5s3e /some/path

But it definitely does not do any prepending if "ada0s1a" is already recorded in
f_mntfromname.

My guess is that the easiest way to avoid this ambiguity and the confusion that it
causes (like the problem you described above) is to prepend "/dev/", if it's
missing, right in vfs_mountroot.c before calling kernel_mount().

In any case, this issue should be very rare in practice.

-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50801E32.80309>