From nobody@FreeBSD.org  Fri Jan 14 20:58:21 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id A5CBF1065674
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 Jan 2011 20:58:21 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 7B25A8FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 Jan 2011 20:58:21 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p0EKwLXn097054
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 14 Jan 2011 20:58:21 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p0EKwLkh097053;
	Fri, 14 Jan 2011 20:58:21 GMT
	(envelope-from nobody)
Message-Id: <201101142058.p0EKwLkh097053@red.freebsd.org>
Date: Fri, 14 Jan 2011 20:58:21 GMT
From: alexander naumochkin <alexander.naumochkin@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: zfs root mount error while kernel is not located in /boot/kernel
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         153996
>Category:       kern
>Synopsis:       [zfs] zfs root mount error while kernel is not located in /boot/kernel
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-fs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 14 21:00:20 UTC 2011
>Closed-Date:    
>Last-Modified:  Wed Jan 19 18:00:19 UTC 2011
>Originator:     alexander naumochkin
>Release:        8.2-PRERELEASE (SNAP-20110110) i386
>Organization:
>Environment:
FreeBSD zombie.prio.ru 8.2-PRERELEASE FreeBSD 8.2-PRERELEASE #0: Tue Jan 11 01:17:21 MSK 2011     root@zombie.prio.ru:/usr/obj/usr/src/sys/GCAM  i386
>Description:
If the kernel is not located in default directory (/boot/kernel), it fails to mount zfs root during startup regardless of using vfs.root.mountfrom="zfs:zroot" or /etc/fstab record.

I use FreeBSD on GPT ZFS Root.


[ash@zombie ~]$ gpart show
=>       34  156301421  ada0  GPT  (75G)
         34        128     1  freebsd-boot  (64K)
        162    3145728     2  freebsd-swap  (1.5G)
    3145890  153155565     3  freebsd-zfs  (73G)

=>       34  156301421  ada1  GPT  (75G)
         34        128     1  freebsd-boot  (64K)
        162    3145728     2  freebsd-swap  (1.5G)
    3145890  153155565     3  freebsd-zfs  (73G)

[ash@zombie ~]$ gpart show -l
=>       34  156301421  ada0  GPT  (75G)
         34        128     1  (null)  (64K)
        162    3145728     2  swap0  (1.5G)
    3145890  153155565     3  disk0  (73G)

=>       34  156301421  ada1  GPT  (75G)
         34        128     1  (null)  (64K)
        162    3145728     2  swap1  (1.5G)
    3145890  153155565     3  disk1  (73G)

[ash@zombie ~]$ zpool status
  pool: zroot
 state: ONLINE
 scrub: none requested
config:

        NAME           STATE     READ WRITE CKSUM
        zroot          ONLINE       0     0     0
          mirror       ONLINE       0     0     0
            gpt/disk1  ONLINE       0     0     0
            gpt/disk0  ONLINE       0     0     0

>How-To-Repeat:
#cd /usr/src
#make installkernel KODIR=/boot/GCAM
#shutdown -r now

Select 6 (loader prompt) from boot menu and enter:

OK unload kernel
OK load /boot/GCAM/kernel
OK set module_path=/boot/GCAM
OK load opensolaris
OK load zfs
OK boot

kernel starts, detects hardware, but at "Trying to mount root from zfs:zroot" stops with "MOUNT ROOT ERROR:"  Entering zfs:zroot at mountroot> prompt not helps.
>Fix:
Boot from LiveCD, mount zroot, rename /boot/GCAM to /boot/kernel, reboot :)

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Jan 16 23:15:52 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=153996 

From: Garrett Cooper <gcooper@FreeBSD.org>
To: bug-followup@FreeBSD.org, alexander.naumochkin@gmail.com
Cc:  
Subject: Re: kern/153996: [zfs] zfs root mount error while kernel is not
 located in /boot/kernel
Date: Mon, 17 Jan 2011 16:56:27 -0800

 Alexander,
     Have you tried setting kernelname to GCAM in your loader.conf
 before booting (it's not documented in loader.conf but it's a part of
 boot)?
     Another item I use to switch between kernels is symlink the suckers:
 
 $ ls -l /boot/kernel
 lrwxr-xr-x  1 root  wheel  17 Jan 13 17:35 /boot/kernel -> BAYONETTA.r217362
 
     This works well.
 HTH,
 -Garrett

From: Alexander Naumochkin <alexander.naumochkin@gmail.com>
To: Garrett Cooper <gcooper@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: kern/153996: [zfs] zfs root mount error while kernel is not
 located in /boot/kernel
Date: Tue, 18 Jan 2011 19:37:11 +0300

 --0016362851685385ff049a2184a1
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable
 
 Garrett,
 
 now I have two kernels on my box:
 1. /boot/kernel/kernel =E2=80=94 my working customized kernel
 2. /boot/GENERIC/kernel =E2=80=94 GENERIC kernel
 
 I tried the following expreriment:
 
 # shutdown -r now
 
 wait for loader menu and choose 6 - Escape to loader prompt
 
 OK unload kernel
 OK set kernelname=3D/boot/GENERIC/kernel
 OK set module_path=3D/boot/GENERIC
 OK load opensolaris
 OK load zfs
 OK boot
 
 and got the same result: "MOUNT ROOT ERROR" while "Trying to mount root fro=
 m
 zfs:zroot"
 
 BTW, even if your method would work, it could not help in case of install
 misconfigured unbootable kernel. Let's say I install misconfigured kernel:
 
 # make installkernel KERNCONF=3DBADKRNL
 
 After this I get:
 
 1. bad kernel in /boot/kernel/kernel
 2. previous working kernel in /boot/kernel.old/kernel
 3. GENERIC kernel in /boot/GENERIC/kernel
 
 I reboot and faced with unbootable system (because of BADKRNL as default).
 In fact we have now completely unbootable system due the bug I've reported
 with this PR. Also this bug means that from now on we have no possibility t=
 o
 test custom kernels by installing it to alternate directory (with KODIR
 variable) =E2=80=94 it will not boot anyway.
 
 Regards,
 /Alexander
 
 On Tue, Jan 18, 2011 at 3:56 AM, Garrett Cooper <gcooper@freebsd.org> wrote=
 :
 
 > Alexander,
 >    Have you tried setting kernelname to GCAM in your loader.conf
 > before booting (it's not documented in loader.conf but it's a part of
 > boot)?
 >    Another item I use to switch between kernels is symlink the suckers:
 >
 > $ ls -l /boot/kernel
 > lrwxr-xr-x  1 root  wheel  17 Jan 13 17:35 /boot/kernel ->
 > BAYONETTA.r217362
 >
 >    This works well.
 > HTH,
 > -Garrett
 >
 
 
 
 --=20
 /ash
 
 --0016362851685385ff049a2184a1
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable
 
 Garrett,<div><br></div><div>now I have two kernels on my box:</div><div>1. =
 /boot/kernel/kernel =E2=80=94 my working customized kernel</div><div>2. /bo=
 ot/GENERIC/kernel =E2=80=94 GENERIC kernel</div><div><br></div><div>I tried=
  the following expreriment:</div>
 
 <div><br></div><div># shutdown -r now</div><div><br></div><div>wait for loa=
 der menu and choose 6 - Escape to loader prompt</div><div><br></div><div>OK=
  unload kernel</div><div>OK set kernelname=3D/boot/GENERIC/kernel</div><div=
 >
 
 OK set module_path=3D/boot/GENERIC</div><div>OK load opensolaris</div><div>=
 OK load zfs</div><div>OK boot</div><div><br></div><div>and got the same res=
 ult: &quot;MOUNT ROOT ERROR&quot; while &quot;Trying to mount root from zfs=
 :zroot&quot;</div>
 
 <div><br></div><div>BTW, even if your method would work, it could not help =
 in case of install misconfigured unbootable kernel. Let&#39;s say I install=
  misconfigured kernel:</div><div><br></div><div># make installkernel KERNCO=
 NF=3DBADKRNL</div>
 
 <div><br></div><div>After this I get:</div><div><br></div><div>1. bad kerne=
 l in /boot/kernel/kernel</div><div>2. previous working kernel in /boot/kern=
 el.old/kernel</div><div>3. GENERIC kernel in /boot/GENERIC/kernel</div>
 
 <div><br></div><div>I reboot and faced with unbootable system (because of B=
 ADKRNL as default). In fact we have now completely unbootable system due th=
 e bug I&#39;ve reported with this PR. Also this bug means that from now on =
 we have no possibility to test custom kernels by installing it to alternate=
  directory (with KODIR variable) =E2=80=94 it will not boot anyway.<br>
 
 <br></div><div>Regards,</div><div>/Alexander</div><div><br><div class=3D"gm=
 ail_quote">On Tue, Jan 18, 2011 at 3:56 AM, Garrett Cooper <span dir=3D"ltr=
 ">&lt;<a href=3D"mailto:gcooper@freebsd.org">gcooper@freebsd.org</a>&gt;</s=
 pan> wrote:<br>
 
 <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
 x #ccc solid;padding-left:1ex;">Alexander,<br>
  =C2=A0 =C2=A0Have you tried setting kernelname to GCAM in your loader.conf=
 <br>
 before booting (it&#39;s not documented in loader.conf but it&#39;s a part =
 of<br>
 boot)?<br>
  =C2=A0 =C2=A0Another item I use to switch between kernels is symlink the s=
 uckers:<br>
 <br>
 $ ls -l /boot/kernel<br>
 lrwxr-xr-x =C2=A01 root =C2=A0wheel =C2=A017 Jan 13 17:35 /boot/kernel -&gt=
 ; BAYONETTA.r217362<br>
 <br>
  =C2=A0 =C2=A0This works well.<br>
 HTH,<br>
 <font color=3D"#888888">-Garrett<br>
 </font></blockquote></div><br><br clear=3D"all"><br>-- <br>/ash<br>
 </div>
 
 --0016362851685385ff049a2184a1--

From: Martin Simmons <martin@lispworks.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/153996: [zfs] zfs root mount error while kernel is not located in /boot/kernel
Date: Wed, 19 Jan 2011 15:16:03 GMT

 The same happens in 8.0 (with LOADER_ZFS_SUPPORT=YES).  I suspect the problem
 is that unload removes the zpool.cache from memory, so zfs can't find the pool
 any more.  You can see that by doing lsmod before unload.
 
 Either reload it like this before boot:
 
 load -t /boot/zfs/zpool.cache /boot/zfs/zpool.cache
 
 or reload everything with boot's kernel & module loader:
 
 unload
 set module_path=/boot/GCAM
 boot /boot/GCAM/kernel
 
 The second way assumes your loader.conf contains zfs_load="YES", which it
 probably does in this case.

From: Garrett Cooper <gcooper@FreeBSD.org>
To: Alexander Naumochkin <alexander.naumochkin@gmail.com>
Cc: bug-followup <bug-followup@freebsd.org>
Subject: Re: kern/153996: [zfs] zfs root mount error while kernel is not
 located in /boot/kernel
Date: Wed, 19 Jan 2011 09:54:45 -0800

 On Wed, Jan 19, 2011 at 9:17 AM, Alexander Naumochkin
 <alexander.naumochkin@gmail.com> wrote:
 > Wow! It starts! I've just typed boot GENERIC, and it starts and works!
 > Thank you very much Garrett!
 >
 > This will continue forever in next releases? I think it should be
 > documented in Handbook. How can I participate? If I can ever :)
 >
 > On Wed, Jan 19, 2011 at 12:20 PM, Garrett Cooper <gcooper@freebsd.org> wr=
 ote:
 >>
 >> On Tue, Jan 18, 2011 at 8:37 AM, Alexander Naumochkin
 >> <alexander.naumochkin@gmail.com> wrote:
 >> > Garrett,
 >> > now I have two kernels on my box:
 >> > 1. /boot/kernel/kernel =97 my working customized kernel
 >> > 2. /boot/GENERIC/kernel =97 GENERIC kernel
 >> > I tried the following expreriment:
 >> > # shutdown -r now
 >> > wait for loader menu and choose 6 - Escape to loader prompt
 >> > OK unload kernel
 >> > OK set kernelname=3D/boot/GENERIC/kernel
 >> > OK set module_path=3D/boot/GENERIC
 >> > OK load opensolaris
 >> > OK load zfs
 >> > OK boot
 >> > and got the same result: "MOUNT ROOT ERROR" while "Trying to mount roo=
 t from
 >> > zfs:zroot"
 >> > BTW, even if your method would work, it could not help in case of inst=
 all
 >> > misconfigured unbootable kernel. Let's say I install misconfigured ker=
 nel:
 >> > # make installkernel KERNCONF=3DBADKRNL
 >> > After this I get:
 >> > 1. bad kernel in /boot/kernel/kernel
 >> > 2. previous working kernel in /boot/kernel.old/kernel
 >> > 3. GENERIC kernel in /boot/GENERIC/kernel
 >> > I reboot and faced with unbootable system (because of BADKRNL as defau=
 lt).
 >> > In fact we have now completely unbootable system due the bug I've repo=
 rted
 >> > with this PR. Also this bug means that from now on we have no possibil=
 ity to
 >> > test custom kernels by installing it to alternate directory (with KODI=
 R
 >> > variable) =97 it will not boot anyway.
 >>
 >> Try set kernelname=3DGENERIC , etc. Or... just load the kernel modules
 >> and do: boot GENERIC, etc on the loader command line.
 
      It's been this way for ages with loader(8), so I doubt it's going
 to change too dramatically anytime soon :). That being said, the
 handbook [1] might need to be updated a bit with a working process (or
 unload needs to be properly fixed to unload everything if it's broken
 -- not sure). I'll have to see what happens when I issue those
 commands sometime on the command line.
      Regardless though -- if the process doesn't work as-is you should
 submit a doc update for the handbook so that a working process is
 available for end-users :).
 Cheers!
 -Garrett
 
 1. http://www.freebsd.org/doc/handbook/boot-blocks.html
>Unformatted:
