====== How to boot a FreeBSD system in any partitions with loader.efi ====== In about FreeBSD 12.0-RELEASE, ''loader.efi'' has been used as UEFI bootloader instead of prior ''boot.efi''. Both loaders can boot a FreeBSD system from ZFS or UFS file system. The loader.efi only looks for the boot file system from the disk which the loader is loaded from, though the boot1.efi does it from its disk and also another disks. Briefly speaking, current loader.efi can't boot the system from other disks. Well, it can do it if we manually operate to set the boot devices in loader prompt each time, but this is not realistic way. I thought that it somehow got be able to automatically boot the system from other disks, then I read some documents and googled, but there was no idea. After I reluctantly saw [[https://github.com/freebsd/freebsd-src/tree/master/stand/efi/loader|the source codes of loader.efi]], I found a way using a ''loader.env'' file and a ''rootdev'' variable. Regardless of loader.efi or boot1.efi, it eventually uses the value of ''currdev'' variable as a boot target. In loader.efi, [[https://github.com/freebsd/freebsd-src/blob/de1aa3dab23c06fec962a14da3e7b4755c5880cf/stand/efi/loader/main.c#L509|the 'currdev' is set from a 'rootdev' variable unquestionably if it exists]]. And then, it seems the ''rootdev'' is set by ''/efi/freebsd/loader.env'' file in ESP. This function is [[https://github.com/freebsd/freebsd-src/commit/8ac2d6f5d65afd9ae3d25141a39d63cdc0b39898|developed relatively recently]], then [[https://github.com/freebsd/freebsd-src/commit/54f346e543c2b223125c28773cd2059aece9559b|FreeBSD 12.2-RELEASE and over support it]]. Add a following line to the file to specify the file system path corresponding to root directory in ZFS. The value becomes like ''disk0p1'' in UFS. Suffix colon is not wrong, it's necessary! rootdev=zfs:zroot/ROOT/default: They are undocumented as of 9th January 2021, so they may change in the future and also as-is. Of course, I simply use prior boot1.efi with no need to such a chore way.