Solved manually installing FreeBSD (without bsdinstall)

I am migrating away from bsdinstall because of the interactive prompts and so I can better control logging. I am unable to boot my new system which I suspect is me not running efibootmgr properly.

I am doing a GPT label with UEFI only. I create an ESP and a ZFS partition, the ESP is 260 MB in size, and the ZFS Pool fills the rest on top of GELI.

During the install, I:
1. mount ESP @ /boot/efi
2. copy efi files to the ESP
3. run efibootmgr --create --activate --label "FreeBSD" --loader "/mnt/boot/efi/efi/freebsd/loader.efi" > /dev/null

The above command returns successfully.

Upon rebooting, I get the error:
Ignoring Boot0000: Only one DP found
Trying ESP: ...
Setting currdev to disk1p1
Trying: ...
Setting currdev to disk1p2
Failed to find bootable partition

I don't see any other errors, but the only other thing that stands out to me is when booting up to the installation media and running efibootmgr -v, the path to the loader appears to still reference /mnt which doesn't make sense because that is where it was mounted during installation.

I am going through bsdinstall/bootconfig, but I think I am performing all the steps there.

I came across another post with a similar error, but he resolved it by clearing ZFS labels, but his error also has some other errors which I don't have. I did not wipe all my ZFS labels as I am initializing GELI, so that would nuke those anyways.

Any ideas?
 
Thanks, but AFAIK, the file must exist as the location provided and efibootmgr translates it when writing the UEFI entry. My command above is matching the /usr/libexec/bsdinstall/zfsboot syntax once the variables are all evaluated to my knowledge - I did not step through or do set -x, but read through the script keeping track of the value along the way.

I tried that after booting up to the install media and it says no such file or directory, so the loader file must exist at that location.
 
You said the ESP is mounted at /boot/efi. If it is, /boot/efi/efi/freebsd/loader.efi exists and that should work. If not, you have to mount it wherever you want and point to the right path/file.

What is for sure is that /mnt/boot/efi/efi/freebsd/loader.efi doesn't exist.
 
Upon rebooting, I get the error:
Code:
Ignoring Boot0000: Only one DP found
Trying ESP: ...
Setting currdev to disk1p1
Trying: ...
Setting currdev to disk1p2
Failed to find bootable partition
This doesn't look like a loader problem. Those messages come from the loader. See this snapshot image from a vbox VM:

efi-loader.png



Code:
 Failed to find bootable partition
Are "geom_eli_load" and "zfs_load" set in /boot/loader.conf?
 
This doesn't look like a loader problem.
Yes, you're right. I had overlooked this fact, drowned out by the description of the problem which points to a false culprit.

There is an old but excellent howto about an installation from scratch: https://forums.freebsd.org/threads/installing-freebsd-manually-no-installer.63201/

I tried it when I was near the beginning of FreeBSD use. It worked perfectly.
I think at this among others things:
zpool set bootfs=zroot zroot
 
Oh, you're probably right, I think I missed that, let me check.

EDIT:
That did it.

Thanks,

I will go through the referenced document as well.
 
I reran my automated installer with that line added and am having the issue again, strange. I'm scratching my head.

I booted to the FreeBSD installer thumb drive and saw the bootfs property was set as expected.

When I rerun the installer, it should be wiping all labels, ZFS labels, etc. It is strange that it worked the first time after setting the bootfs pool property, but now it isn't. The only thing I can think of is that I did NOT wipe the efi boot entries before the install, but wiped them after, and then re-added it back only to end up where I was.
 
I still need some help ... I cannot figure out what I did.

I reran my automated installer a few times after making the above changes, but it will not boot. My system is booting via UEFI and GPT and I have partitioned only a 260M ESP and the remainder GELI with ZFS.

1. gpart destroy -F
2. zpool labelclear -f
3. gpart create -s gpt
4. gpart add -a 4k -l efiboot0 -t efi -s 260M
5. newfs_msdos
6. gpart add -a 1m -l boot0 -t freebsd-zfs
7. geli init
8. zpool create
9. zfs create
10. zpool set bootfs=dataset pool

Step 10 is what I think I missed before and that appeared to have resolve my issue then. But now, with all of this automatically being done, it ends up the same, unable to boot with the same error above.

I checked the bootfs property was set on the pool and as best as I can tell, it is and matches the dataset name. Furthermore, the ESP appears to have the efi files in the right place.

I was thinking that perhaps an old ZFS label might be causing an issue, but I also ran this on another machine.
 
I still need some help ... I cannot figure out what I did.
Try this custom script for non-interactive (except geli passphrase enter) encrypted Root-on-ZFS installation. If the installation goes well, compaire with your script.

Assuming /usr/freebsd-dist/{kernel.txz base.txz} are on the installing host system (installer media).

Addapt disk device names in the script according to the machines device naming.

Eventually remove multiple FreeBSD EFI menu entries.
sh:
#!/bin sh

gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -t efi -a 4k -s 260m -l efiboot0 ada0
gpart add -t freebsd-zfs -a 1m -l zfs0 ada0

newfs_msdos -c 1 -F 32 /dev/ada0p1
mount_msdosfs /dev/ada0p1 /media

mkdir -p /media/efi/freebsd
cp -a /boot/loader.efi /media/efi/freebsd

umount /media

efibootmgr -c -a -L FreeBSD -l ada0p1:/efi/freebsd/loader.efi

echo
echo

geli init -g -l 256 -s 4096 ada0p2
geli attach ada0p2

zpool create -o ashift=12 -o altroot=/mnt -O compression=on -O atime=off -m none zroot ada0p2.eli

zfs create -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ zroot/ROOT/default

zfs create -o mountpoint=/home zroot/home
zfs create -o mountpoint=/tmp -o exec=on -o setuid=off zroot/tmp

zfs create -o mountpoint=/usr -o canmount=off zroot/usr
zfs create -o setuid=off zroot/usr/ports

zfs create zroot/usr/src

zfs create -o mountpoint=/var -o canmount=off zroot/var
zfs create -o exec=off -o setuid=off zroot/var/audit

zfs create -o exec=off -o setuid=off zroot/var/crash
zfs create -o exec=off -o setuid=off zroot/var/log

zfs create -o atime=on zroot/var/mail
zfs create -o setuid=off zroot/var/tmp

zfs set mountpoint=/zroot zroot

mkdir -p /mnt/tmp
chmod 1777 /mnt/tmp/

mkdir -p /mnt/var/tmp
chmod 1777 /mnt/var/tmp

zpool set bootfs=zroot/ROOT/default zroot

mkdir -p /mnt/boot/zfs

zpool set cachefile=/mnt/boot/zfs/zpool.cache zroot

zfs set canmount=noauto  zroot/ROOT/default

echo
echo Extracting distribution files
echo

tar xfC /usr/freebsd-dist/kernel.txz /mnt
tar xfC /usr/freebsd-dist/base.txz /mnt

cat << EOF > /mnt/boot/loader.conf
kern.geom.disk_ident.enable="0"
kern.geom.gptid.enable="0"
geom_eli_load="YES"
cryptodev_load="YES"
zfs_load="YES"
EOF

cat << EOF > /mnt/etc/rc.conf
hostname="example.com"
ifconfig_DEFAULT="DHCP"
sshd_enable="YES"
dumpdev="AUTO"
zfs_enable="YES"
EOF

cat << EOF > /mnt/etc/fstab
/dev/gpt/efiboot0   /boot/efi   msdosfs   rw   2   2
EOF

echo vfs.zfs.min_auto_ashift=12 >> /mnt/etc/sysctl.conf

cp /var/backups/* /mnt/var/backups

echo
echo Installation finished
echo
 
I saw some differences and tried those, but no avail.

1. I did not specify -F 32, but I don't believe that mattered
2. my gpart label was zfsboot0 not zfs0
3. I ran zpool labelclear, the above script did not, but my other installs don't appear to have that
4. I did not set a cachefile

I updated my script with the above and completed running it but am right back where I started.
 
Oh, I was going through again, I apparently changed geli init and excluded -g (enable booting) ... let me try that
 
Back
Top