Re: A little question about safe mode

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Thu, 18 Oct 2012 18:20:18 +0300
on 18/10/2012 16:50 Alexander Yerenkow said the following:
> 
> 
> 2012/10/18 Andriy Gapon <avg_at_freebsd.org <mailto:avg_at_freebsd.org>>
> 
>     on 18/10/2012 12:11 Alexander Yerenkow said the following:
>     > 2012/10/18 Andriy Gapon <avg_at_freebsd.org <mailto:avg_at_freebsd.org>
>     <mailto:avg_at_freebsd.org <mailto:avg_at_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
Received on Thu Oct 18 2012 - 13:20:23 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:31 UTC