Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Aug 2012 17:06:48 +0200
From:      Jeremie Le Hen <jlh@FreeBSD.org>
To:        "Andrey V. Elsukov" <bu7cher@yandex.ru>
Cc:        Jeremie Le Hen <jlh@FreeBSD.org>, freebsd-fs@FreeBSD.org
Subject:   Re: Cannot get zfsboot prompt
Message-ID:  <20120827150648.GE32062@felucia.tataz.chchile.org>
In-Reply-To: <503B4521.9080603@yandex.ru>
References:  <20120827070210.GA798@felucia.tataz.chchile.org> <503B4521.9080603@yandex.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 27, 2012 at 02:00:01PM +0400, Andrey V. Elsukov wrote:
> 
> When i'm configuring ZFS-only system, usually i do the following steps:
> 1. zpool create -R /mnt bsdroot ada0s1a
> 2. Create several filesystems and install the system.
> 3. zpool set bootfs=bsdroot/root bsdroot
> 4. zpool set cachefile=/mnt/boot/zfs/zpool.cache bsdroot
> 5. echo 'vfs.root.mountfrom="zfs:bsdroot/root"' >> /boot/loader.conf
>    echo 'zfs_load="YES"' >> /boot/loader.conf
> 6. echo 'zfs_enable="YES"' >> /etc/rc.conf
> 7. Add swap entry to the /etc/fstab
> 8. zpool set mountpoint=none bsdroot/root
> 9. zpool set mountpoint=none bsdroot
> 10. Write bootcode:
> >   dd if=/mnt/boot/zfsboot of=/dev/ada0s1 count=1
> >   dd if=/mnt/boot/zfsboot of=/dev/ada0s1 skip=1 seek=1024
> 
> I guess your ada0s1a partition has non zero offset, and second
> part of zfsboot bootcode has been written into wrong place.
>
> AFAIK, the first part of the zfsboot does read the second part
> from the 1024 sector of the active FreeBSD slice in the MBR.

Yes I agree this is probably where the catch is.  But note that contrary
to your procedure, I laid zfsboot2 from ada0s1a.

The first partition of my BSD label indeed starts at sector 1.

rescue-bsd# gpart show ada0s1
=>         0  1953525105  ada0s1  BSD  (931G)
           0           1          - free -  (512B)
           1  1951799000       1  freebsd-zfs  (930G)
  1951799001     1726096       4  freebsd-swap  (842M)
  1953525097           8          - free -  (4.0k)

>From what I undestand from sys/boot/i386/zfsboot/zfsldr.S, zfsboot1
expects zfsboot2 to be at offset 1024 for the start of the first FreeBSD
(0xA5) MBR active slice (fall-back to non-active).  1024 sectors is not
chosen randomly, this is because in zpools, the boot block is located
after the two heading vdev label replicas which are 256KB each.

Given my partition in shifted by one sector, zfsboot2 is shifted by one
sector as well so zfsboot1 doesn't find it.

Do you know if this topic is documented somewhere?  I couldn't find
anything when I needed it.

Also, why does gpart(8) enforce a one sector offset for partition inside
a BSD scheme?  I tried to set an offset to 0 without any effect.

Regards,
-- 
Jeremie Le Hen

Scientists say the world is made up of Protons, Neutrons and Electrons.
They forgot to mention Morons.



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