Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Jun 2014 07:22:29 -0500
From:      Karl Denninger <karl@denninger.net>
To:        freebsd-stable@freebsd.org
Subject:   Re: ZFS boot pool selection
Message-ID:  <53906105.2080302@denninger.net>
In-Reply-To: <53902B1D.8030200@ish.com.au>
References:  <53902B1D.8030200@ish.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]

On 6/5/2014 3:32 AM, Aristedes Maniatis wrote:
> I'd like to better understand the boot process as it applies to a ZFS on root approach in FreeBSD 9 or 10 using GPT. What I understand so far:
>
> A. BIOS is able to execute some code placed in a special partition on a GPT formatted disk. This code is 40kB of hand crafted code and installed using:
>
> gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
>
> The partition itself must be created as
>
> gpart add -s 222 -a 4k -t freebsd-boot -l boot0 ada0
>
>
> B. For older BIOS systems without knowledge of GPT, the pmbr is installed in some other special location on the disk, outside any partitions. This is 512 bytes of code and does nothing other than pretend to be MBR to tell the old BIOS (or Windows?) to not mess with this disk.
>
> 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.
>
>
>
> Questions
>
> 1. If I have two zpools on this machine, how does gptzfsboot know which one to boot the kernel from? Does it just start by iterating through all zfs partitions until it finds the zpool metadata cache which give it enough information to mount some zpool? In other words, does it pick a random pool from what it can access?
It looks at the pools until it finds "bootfs" defined on one of them, 
which tells it where to boot from.
>
> 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?
Once it has found "bootfs" it expects the usual structures to be there 
(e.g. the "/boot" directory)
>
> 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. Can we omit vfs.root.mountfrom entirely?
I do not have it in my /boot/loader.conf file.

I have "beadm" set up which allows me to snapshot the existing running 
system structure off my root pool (a separate pool from where data 
lives) and then start it in a jail and perform an update on it there.  I 
can then swap to it on the next boot if I wish while retaining the 
previous system copy (in case something goes wrong.)
>
>
> I understand grub a little better, since in that case you configure, then install a new configured grub artifact into the right places. But with the FreeBSD boot process there seems to be no configuration of the first stage boot loader.
>
>
> Thanks very much for helping me to understand this boot process in more detail
>
>
> Cheers
> Ari
>
>

-- 
-- Karl
karl@denninger.net



[-- Attachment #2 --]
0	*H
010	+0	*H
O0K030
	*H
010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1/0-	*H
	 customer-service@cudasystems.net0
130824190344Z
180823190344Z0[10	UUS10UFlorida10UKarl Denninger1!0	*H
	karl@denninger.net0"0
	*H
0
bi՞]MNԿawx?`)'ҴcWgR@BlWh+	u}ApdCFJVй~FOL}EW^bچYp3K&ׂ(R
lxڝ.xz?6&nsJ+1v9v/(kqĪp[vjcK%fϻe?iq]z
lyzFO'ppdX//Lw(3JIA*S#՟H[f|CGqJKooy.oEuOw$/섀$삻J9b|AP~8]D1YI<"""Y^T2iQ2b	yH)]	Ƶ0y$_N6XqMC 9՘	XgώjGTP"#nˋ"Bk100	U00	`HB0U0,	`HB
OpenSSL Generated Certificate0U|8˴d[20U#0]Af4U3x&^"408	`HB+)https://cudasystems.net:11443/revoked.crl0
	*H
gBwH]j\x`(&gW32"Uf^.^Iϱ
k!DQAg{(w/)\N'[oRW@CHO>)XrTNɘ!u`xt5(=f\-l3<@C6mnhv##1ŃbH͍_Nq
aʷ?rk$^9TIa!kh,D-ct1
00010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1/0-	*H
	 customer-service@cudasystems.net0	+;0	*H
	1	*H
0	*H
	1
140605122229Z0#	*H
	1 y;ǜOἁ!w0l	*H
	1_0]0	`He*0	`He0
*H
0*H
0
*H
@0+0
*H
(0	+710010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1/0-	*H
	 customer-service@cudasystems.net0*H
	1010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1/0-	*H
	 customer-service@cudasystems.net0
	*H
jͯ[2O$J{Vi4`
i^ټ'ns`"D*-A"_)~hiGe`y\Ca.I֘Z0d㤕	|cϿq20'h6ctY8&V̍i/@qZX=< BjR
8I?]h
Ls-$X]͹e_>ko`^m9yc\PVO}GXvӌQ(OVk{uJb'DۤU(t͚A	*3.n}"+vǨ{PZgPc2P4K3sB"L`Wu$9 h&R9I 	:olA`k	ׅ*~++RMސ]娫5g	8UT]dJݠFr!VYA}Q,-f]:/
L iE?ZP)1A[0

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