1

I have one hard drive that I want to split into two separate FreeBSD OS installs and I'm running into a wall trying to figure out how to get it working.

I followed Installing FreeBSD Root on ZFS using GPT in order to get a single OS up and running. There are no problems and everything works great. However, I do not know how to modify this in order to get a second OS up and running.

I repeat from steps 2 onward to create the second partition and second zpool.

Once I restart the FreeBSD boot menu does not show any boot options (i.e. no option for Boot Environment in option 8).

If I do a zpool import it will show my second zpool that is a part of the other partition.

I can even mount it using zpool import -R /mnt zroot2 and I can see the files.

This is the point I'm quite lost. I can't figure out what I did to do. I looked into efibootmgr and bectl, but I'm not sure either is the right option. bectl seems to create Boot Environments from snapshots and not from other partitions. efibootmgr seems to need the file system mounted.

Essentially my current progress is:

  • nda0p1 efi
  • nda0p2 freebsd-swap
  • nda0p3 freebsd-zfs (OS 1)
  • nda0p4 freebsd-zfs (OS 2)

How do I get the FreeBSD boot manager to recognize the second OS?

edit1: I tried installing twice through the UI and it did put another entry into the efibootmgr, but both options boot the newest install even though they point to separate files (\EFI\BOOT\BOOTX64.efi and \EFI\freebsd\loader.efi). The original install doesn't boot.

edit2: I think the reason they both boot the same instance is they're both the same UI. You copy the efi into to the BOOTX64.efi location in the steps from above. From what I understand this efi automatically finds the FreeBSD instance.

How does one create an EFI that points directly to an instance?

1
  • 2
    Why do you need 2 installs? Can you not use a jail? Commented Jul 28 at 16:23

1 Answer 1

3

How do you handle your multiboot? Do you use your motherboard's manufacturer menu or some loader (rEFInd for example)?

I can be wrong but you should be able to boot the filesystem you want by specifying the rootdev environment variable to the FreeBSD loader.

With your motherboard's manufacturer menu, you have to use efibootmgr and create 2 entries (you can use the same BOOTX64.efi/loader.efi for both as long as both systems are compatible with it - it depends on their respective FreeBSD version). From one of your system:

# mount the EFI partition # reminder: BOOTX64.efi is a copy of /boot/loader.efi # adapt rootdev if you are not using BE on zroot1 efibootmgr -a -c -l /path/to/your/BOOTX64.efi -L "system 1" -e "rootdev=zfs:zroot1/ROOT/default:" # adapt rootdev if you are not using BE on zroot2 efibootmgr -a -c -l /path/to/your/BOOTX64.efi -L "system 2" -e "rootdev=zfs:zroot2/ROOT/default:" # unmount the EFI partition 

Using rEFInd, install it and specify rootdev in refind.conf:

menuentry "System 1" { loader \efi\path\to\freebsd\loader.efi # adapt rootdev if you are not using BE on zroot1 options "rootdev=zfs:zroot1/ROOT/default:" } menuentry "System 2" { loader \efi\path\to\freebsd\loader.efi # adapt rootdev if you are not using BE on zroot2 options "rootdev=zfs:zroot2/ROOT/default:" } 

PS: in case you are not sure for the value of rootdev, it should have the same value than df / | tail -n +2 | cut -wf 1 in the system you booted into (with the prefix zfs: and suffixed by :).

4
  • I am using my manufacturer menu and not 'rEFInd. You're missing the zfs:` portion of the rootdev in your efibootmgr commands. Unfortunately, both entries booted the same zroot instead of ztest even though the rootdev entry was different. This seemed promising though and might be the right track. Commented Jul 29 at 17:11
  • Never mind, it had to be something I did while experimenting around (perhaps even mounting the other system temporarily). I just ran through my restore script to redo the install of both systems and tried again with the efibootmgr commands and it seems to work now. Thank you for the help. The key was the rootdev option. Commented Jul 29 at 17:34
  • Just a follow-up, where did you find the documentation on rootdev? I didn't see that listed anywhere on the efibootmgr manual. It does list the -e env option, but it doesn't mention that outside of the initial command to explain what env options there are. Commented Jul 29 at 17:48
  • 1
    Glad it helped you. You need to consult loader_simp(8) to find the "options" (section builtin environment variables) because you can set these in multiple ways (/boot/loader.conf, EFI\freebsd\loader.env, ...) Commented Jul 29 at 20:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.