Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Dec 2017 01:24:02 +0700
From:      Eugene Grosbein <eugen@grosbein.net>
To:        Warner Losh <imp@bsdimp.com>
Cc:        Alexey Dokuchaev <danfe@freebsd.org>, "Rodney W. Grimes" <rgrimes@freebsd.org>, Warner Losh <imp@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, src-committers <src-committers@freebsd.org>
Subject:   Re: svn commit: r326809 - head/sys/dev/cardbus
Message-ID:  <5A3BFC42.3020703@grosbein.net>
In-Reply-To: <CANCZdfoYTL1h_eDbWqjR16jqLxiwmmRAjrxz3_o3XHkPK6BZrw@mail.gmail.com>
References:  <201712131338.vBDDcHCM091865@pdx.rh.CN85.dnsmgr.net> <5A3167E1.2000201@grosbein.net> <20171213180801.GA28514@FreeBSD.org> <5A316E7B.8030504@grosbein.net> <20171213182452.GA51526@FreeBSD.org> <5A318150.1000601@grosbein.net> <20171214133854.GB51526@FreeBSD.org> <5A328C81.4040501@grosbein.net> <CANCZdfoYTL1h_eDbWqjR16jqLxiwmmRAjrxz3_o3XHkPK6BZrw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 14, 2017 at 2:36 PM, Eugene Grosbein <eugen@grosbein.net <mailto:eugen@grosbein.net>> wrote:
> 
>     - zfsloader(8) failing to find any ZFS pool after zfsboot(8) successfully
>     loaded and started zfsload(8) from zpool (PR pending, need to collect more info)

I've discovered the source of the problem. Here is scenario:

1. Take disk prevously used for FreeBSD. Erase its first and last megabytes
with dd to start from scratch: dd if=/dev/zero bs=1m count=1 of=... etc.

2. Create MBR with gpart, add two "freebsd" slices: first one for 8GB swap,
second one for ZFS (rest of space), make second slice active.

3. Install boot-loaders: /boot/boot0 (or /boot/mbr, it does not matter)
with gpart to the MBR and zfsboot with dd to second second slice just
as zfsboot(8) manual page instructs. Note that this does NOT change contents
of *second* 512-bytes block of this slice.

4. Create zpool using whole second slice, install FreeBSD 11.1/amd64 there and try to boot it.

MBR loader successfully uses second slice to load and run zfsboot.
zfsboot does its job just fine running zfsloader from ZFS
and passes needed ZFS it to zfsloader.

zfsloader uses libstand(3) trying to find its pool: zfs_probe_partition()
successfully calls libstand's version of open("disk0s1:", O_RDONLY) and skips it
as there is no ZFS. Then, it tries to open("disk0s2:", O_RDONLY) and it fails
returning -1 with errno==2 (ENOENT), so zfsloader fails.

src/tools/tools/bootparttest shows that libstand looks at *second* sector of the slice
and sees leftover of (now non-existing) BSD label there.
And for some reason it prevents zfsloader from using such slice.

I "fixed" this by booting from USB flash drive and dd-ing second sector with zeroes
and now zfsloader runs just fine and starts installed FreeBSD 11 from the pool.

This seems to me as bug in libstand, isn't it?





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5A3BFC42.3020703>