Solved How To Create A Bootdisk That Can Boot A Crypted Zroot Pool?

Hi,

I am wondering if anyone knows how to create a freebsd legacy bootdisk (sata/usbstick/sdcard) that can boot an installed system that is installed on a crypted mirrored zroot pool (default config, da0 ... daX).

The bootdisk (let's call it ada0) should contain the kernel, prompt for geli password, and it should import zroot/ROOT/default from da0,... daX, on boot automatically. ;)

I have already found information to build a bootdisk, but the bootdisk does not work with geli on FreeBSD13.
 
What I did so far ...

I created a boot disk with only one additional partition that contains /boot

gpart create -s gpt ada0
gpart add -a 4k -s 512K -t freebsd-boot ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
gpart add -t freebsd-ufs ada0
newfs -U -O1 /dev/ada0p2
mount /dev/ada0p2 /mnt
cp -r /boot /mnt
echo 'vfs.root.mountfrom="zfs:zroot/ROOT/default"' >> /mnt/boot/loader.conf


But when I boot from that ada0 disk, I get error after geli prompt
can't find /boot/zfsloader
can't find /boot/loader
...
I guess ada0p2 will not be mounted and content of /boot will not be found.

How to fix that?
 
What I did so far ...

I created a boot disk with only one additional partition that contains /boot

gpart create -s gpt ada0
gpart add -a 4k -s 512K -t freebsd-boot ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
gpart add -t freebsd-ufs ada0
newfs -U -O1 /dev/ada0p2
mount /dev/ada0p2 /mnt
cp -r /boot /mnt
echo 'vfs.root.mountfrom="zfs:zroot/ROOT/default"' >> /mnt/boot/loader.conf


But when I boot from that ada0 disk, I get error after geli prompt

I guess ada0p2 will not be mounted and content of /boot will not be found.

How to fix that?

Fix: use /boot/gptboot


gpart create -s gpt ada0
gpart add -a 4k -s 512K -t freebsd-boot ada0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
gpart add -t freebsd-ufs ada0
newfs -U -O1 /dev/ada0p2
mount /dev/ada0p2 /mnt
cp -r /boot /mnt
echo 'vfs.root.mountfrom="zfs:zroot/ROOT/default"' >> /mnt/boot/loader.conf
 
  • Like
Reactions: mer
Very nice. Thanks for sharing. I don't have a use for it (yet), but who knows? That's what I like about this forum and FreeBSD in general: sharing the knowledge, the "teach a man to fish" principle.
 
Back
Top