Solved Install FreeBSD to two partitions on same disk

I am struggling to figure out how to get FreeBSD installed to two partitions on the same disk. My problem, as least as far as I'm aware, is that I cannot figure out how to boot the other installation. I can boot one installation, and I can mount the ZFS partition and see the installed files of the other system, but I cannot figure out how to boot it.

I originally followed Installing FreeBSD Root on ZFS using GPT so I could manually partition the drive to get both installs. I'm not sure how I need to go about modifying those instructions to get the multi-boot working.

I've experimented with efibootmgr. I tried copying another *.efi file to the boot and got it to show up in the efibootmgr, but both entries boot the same OS. Since the *.efi is binary, I'm not sure how, if possible, I can point the two to separate partitions.

I've tried experimenting with boot0cfg, but nothing I do seems to change anything and it just auto-boots the single FreeBSD.

Do I need two EFI partitions? From what I understand I only need one per drive and not one per bootable partition.

How do I configure the EFI to boot two separate partitions? Is it supposed to be automatic where I messed up the install? If that's the case, how do I modify the instructions linked to get it working?

I've done a lot of searching and have come up empty. I even seen this recent thread, but it is about two separate disks and not two partitions on the same drive. It talks about boot0cfg, but I haven't gotten that to work. Most of everything else I see is about Windows and/or Linux and most reference GRUB or rEFInd, but I'm trying to make due without needing third party tools.
 
With ZFS you don't need two separate partitions to boot two FreeBSD installs. You can use boot environments to essentially "dual-boot" different versions of FreeBSD. I have it set up to be able to "dual-boot" 14-STABLE and 15-CURRENT. All from the same zroot pool.

boot0cfg(8) is old, was originally intended to provide a way to boot select an MBR partitioned disk.
 
It's certainly possible, but a little complex and error prone. You can try to create two ESP partitions, each containing different loader.env. See loader.efi(8), paragraph "Additional Environment Variables".

Here, you can then create two efi entries and use the BIOS boot menu to choose your FreeBSD OS. An utility such rEFInd might be used, if the BIOS boot menu is not what you want.

That's just ideas, I don't know if they can work or not.
 
I need the installations to be on separate partitions.
In this case, assuming the machine has UEFI firmware, create UEFI boot manager menu entries for each Root-on-ZFS pool.

In the following example the disk is named ada0, ada0p1 is the ESP partition, pool names "zroot" and "zroot2" (change all naming on your system accordingly).

Pool with name "zroot":
Code:
# efibootmgr  -c  -a  -L  FBzroot  -l  ada0p1:/efi/freebsd/loader.efi  -e  "rootdev=zfs:zroot/ROOT/default:"

Pool with name "zroot2":
Code:
# efibootmgr  -c  -a  -L  FBzroot2  -l  ada0p1:/efi/freebsd/loader.efi  -e  "rootdev=zfs:zroot2/ROOT/default:"

Important here is the "rootdev" environment variable to selects a specific pool to boot from (see loader_simp(8) for doc). Variables will be embedded in the efi menu entry code.

See 15 branch of efibootmgr(8) for "-e" option documentation, the 14 and 13 branches are missing the description.
 
T-Daemon has described how to configure the booting and I have nothing to add there. However, installing the system twice on two separate partitions might be challenging.

And the question remains: Why would you want such a complicated setup? Doing something that other people don't do is a recipe for running into bugs.
 
However, installing the system twice on two separate partitions might be challenging.
Assuming you are satisfied with the standard installer dataset creation, I can help with that, with no individual configuration steps in no time.

Start the installation with the menu guided installer, when in the "ZFS Configuration" menu, set a large "Swap Size" (swap + second Root-on-ZFS partition). After the initial installation has finished, drop to "Live System":
  • delete large swap
  • recreate a smaller freebsd-swap and second freebsd-zfs partition
  • create a pool with your preferred zpoolprops(7) on the second freebsd-zfs
  • take a recursive zfs-snapshot(8) of the initial installed system
  • zfs-send(8), zfs-receive(8) snapshot to second pool
  • change hostname, and other system configuration settings you might want to change on the second pool
 
In this case, assuming the machine has UEFI firmware, create UEFI boot manager menu entries for each Root-on-ZFS pool.

In the following example the disk is named ada0, ada0p1 is the ESP partition, pool names "zroot" and "zroot2" (change all naming on your system accordingly).

Pool with name "zroot":
Code:
# efibootmgr  -c  -a  -L  FBzroot  -l  ada0p1:/efi/freebsd/loader.efi  -e  "rootdev=zfs:zroot/ROOT/default:"

Pool with name "zroot2":
Code:
# efibootmgr  -c  -a  -L  FBzroot2  -l  ada0p1:/efi/freebsd/loader.efi  -e  "rootdev=zfs:zroot2/ROOT/default:"

Important here is the "rootdev" environment variable to selects a specific pool to boot from (see loader_simp(8) for doc). Variables will be embedded in the efi menu entry code.

See 15 branch of efibootmgr(8) for "-e" option documentation, the 14 and 13 branches are missing the description.

Thank you for the tips on setting up efibootmgr. Especially the loader_simp manual. I seen the "-e" option for efibootmgr, but the efibootmgr did not expand on what that was for. Using "rootdev" worked perfectly. I did some quick tests loading using the zpool command to make sure what pool I booted into, I experimented around removing and adding different users, and stuff like that to make sure I was actually in different systems. I appreciate the help and also the liking for more information. I don't know if I'll end up needing other options, but it's a good read anyhow.

T-Daemon has described how to configure the booting and I have nothing to add there. However, installing the system twice on two separate partitions might be challenging.

And the question remains: Why would you want such a complicated setup? Doing something that other people don't do is a recipe for running into bugs.

Installing the system twice was the easy part. ANd people have been dual booting for decades. Windows and Linux is likely the most popular dual boot scenario, and even in the Intel Mac days you had people dual boot macOS and Windows. Dual booting is usually not a complicated setup. My problem was I'm familiar with GRUB, not EFI, and this is also my first time working with ZFS.
 
Back
Top