From owner-svn-src-all@freebsd.org Thu Dec 21 18:24:34 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB8DEE81245; Thu, 21 Dec 2017 18:24:34 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [78.47.246.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FE8C722B9; Thu, 21 Dec 2017 18:24:34 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (root@eg.sd.rdtc.ru [62.231.161.221] (may be forged)) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id vBLIOGMj013814 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Dec 2017 19:24:17 +0100 (CET) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: imp@bsdimp.com Received: from [10.58.0.4] ([10.58.0.4]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTPS id vBLIO5gC044052 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Fri, 22 Dec 2017 01:24:05 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: svn commit: r326809 - head/sys/dev/cardbus To: Warner Losh 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> Cc: Alexey Dokuchaev , "Rodney W. Grimes" , Warner Losh , "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , src-committers From: Eugene Grosbein Message-ID: <5A3BFC42.3020703@grosbein.net> Date: Fri, 22 Dec 2017 01:24:02 +0700 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00, LOCAL_FROM, RDNS_NONE autolearn=no autolearn_force=no version=3.4.1 X-Spam-Report: * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 1.9 RDNS_NONE Delivered to internal network by a host with no rDNS * 2.6 LOCAL_FROM From my domains X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hz.grosbein.net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2017 18:24:34 -0000 On Thu, Dec 14, 2017 at 2:36 PM, Eugene Grosbein > 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?