ZFS boot pool selection

Aristedes Maniatis ari at ish.com.au
Fri Jun 6 02:12:04 UTC 2014


On 6/06/2014 2:30am, Andrey V. Elsukov wrote:

> On 05.06.2014 12:32, Aristedes Maniatis wrote:
>> C. Once gptzfsboot is executing on the CPU, it is able to mount a ZFS
>> pool in read only mode. Enough to read the kernel and get a full ZFS
>> implementation in place.
> 
> gptzfsboot is able to find needed partition and ZFS pool, then it search
> the zfsloader or kernel and without mounting loads and starts it.
> 
> http://www.freebsd.org/cgi/man.cgi?gpart#BOOTSTRAPPING

> AFAIK, it will try to boot from the first ZFS pool that it can find.


Then it would seem that the ZFS property bootfs is pretty much ignored. I know that I've never set it and everything seems to boot fine. Effectively it will load zfsloader from a random pool from all the pools it finds.

Documentation is rather inconsistent too. One page [1] says bootfs should just point to the pool. Another page [2] that it points to the filesystem.

I'm guessing this is inconsistent because that command actually does nothing.

 
>> 2. How does it know where to find the kernel once it mounts the ZFS
>> pool, or is the /boot/kernel location hardcoded into the gptzfsboot
>> code?
> 
> /boot/kernel/kernel is hardcoded. But when zfsloader is used, it has
> some environment variables and you are able to change the kernel location.
> 
>> 3. Once the kernel is booted, then it can read /boot/loader.conf. In
>> there we can see vfs.root.mountfrom="zfs:tank" but isn't this a bit
>> late? We've already mounted this pool and loaded the kernel from it.
> 
> Kernel doesn't read loader.conf. The loader/zfsloader does that.
> 
>> Can we omit vfs.root.mountfrom entirely?
> 
> Yes.


Right, so zfsloader reads loader.conf and uses vfs.root.mountfrom (if it exists) to work out which pool contains the kernel and root filesystem. If vfs.root.mountfrom doesn't exist then it tries the pool that already contains zfsloader. Which makes vfs.root.mountfrom a bit pointless.

When the machine boots the kernel you get dmesg text scrolling by in a light font. I'm guessing that when that font changes to a darker colour that's the point at which the kernel has now mounted the system read-write and it ready to load userland.

Should vfs.root.mountfrom and bootfs be removed from the latest ZFS howto instructions?



Cheers
Ari


[1] # zpool set bootfs=zroot zroot
https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/Mirror

[2] # zpool set bootfs=zroot/ROOT/default zroot
https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE

-- 
-------------------------->
Aristedes Maniatis
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A


More information about the freebsd-stable mailing list