svn commit: r326809 - head/sys/dev/cardbus

Eugene Grosbein eugen at grosbein.net
Thu Dec 21 18:24:34 UTC 2017


On Thu, Dec 14, 2017 at 2:36 PM, Eugene Grosbein <eugen at grosbein.net <mailto:eugen at 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?




More information about the svn-src-all mailing list