Dual-booting FreeBSD 15.1 alongside Gentoo on a shared UEFI disk

I’m about to install FreeBSD 15.1 on a new laptop that already runs Gentoo, and I’d like some advice from people who have done this on a dual-boot machine.

This won't be a daily driver. It’s a test system to make sure my personal C projects build and run on FreeBSD, and just to keep up with what’s happening with FreeBSD in general. I realize I can do this with a VM, but I prefer a bare-metal system that I can use to explore and learn with. I'd prefer relatively-low maintenance, so I’ll be using pkg rather than ports. I’m planning on installing a lightweight LXQt desktop and a standard C/C++ toolchain.

The laptop is a Lenovo ThinkPad E16 Gen 3, Intel Core Ultra 5 (Arrow Lake), 32GB RAM, 2TB NVMe. Wifi is Intel iwlwifi (Bz-generation firmware under Linux). The disk has about 1TB of unpartitioned free space, and Gentoo already has an ESP that I want to reuse.

Question 1: Keeping the ESP safe.
I want to share the existing ESP rather than create a second one. On an older laptop I ended up overwriting the ESP twice with bsdinstall before I got it right, and had to rescue GRUB from a Gentoo live disk. What’s the recommended way to keep bsdinstall away from the existing ESP? My plan is:
  • Choose the Shell option at the partitioning step.
  • Create the root and swap partitions manually with gpart in the free space.
  • Install, then copy loader.efi to EFI/freebsd/ on the ESP myself.
  • Chainload it from GRUB (this worked well for me before).
Is that sound? Does bsdinstall touch the ESP or write EFI/BOOT/BOOTX64.EFI in that mode? Is there a better approach? I’ll back up the ESP first either way.

Question 2: UFS vs ZFS.
I’m leaning towards a single UFS partition mounted on /, with no separate /usr or /home, mainly for simplicity and because Linux can mount UFS read-only for rescue. I have a bit of familiarity with UFS, but have never used ZFS. I know ZFS offers boot environments, but the guided installer wants a whole disk and I’d have to build the pool by hand on a shared disk. For a test machine with 32GB of RAM and little personal data, would you still choose ZFS? If so, what’s the cleanest way to install it into a single partition on a disk shared with another OS?

Thanks!
 
for question 1 , i do not know much to answer, also why not use rEFInd the way it works is somewhat sounds better to me more than grub for dual booting and this stuff

for second go with zfs , it provides to you alot of things that you may like also making pools is not hard at all even on shared disk

For a test machine with 32GB of RAM and little personal data

well , zfs is much useful instant snapshots and other features it provides you will find yourself use them in updates , jails and for other things

anyway you are likely to be fine with UFS too if you want
 
Hey!

I had not heard of eEFInd before, looks like it's an alternative to Grub. I've been using Grub for years, I know how it works, I know how to use the Grub command line to boot kernels if my config gets borked, and perhaps most importantly, it is installed and working already. To be clear, I am not asking for help on how to configure Grub, or to configure the dual boot, I know how to do this already. My question may not have been clear, but I'm really just asking about how to ensure that my ESP does not get touched during the FreeBSD install.

As for UFS vs ZFS, I expect I'll just go for UFS. I don't need RAID, pooling, anything fancy like that. The ARC caching sounds interesting, but I'm not sure it's worth the extra complexity for my use-case. I'll probably only be booting FreeBSD for a few hours once a week to test the source builds of my own projects and otherwise fool around a bit. But as I say, I'm completely ignorant when it comes to ZFS, so there may be benefits I'm not considering, which I why I asked.

Thanks for the reply.
 
Question 1: Keeping the ESP safe.
If you choose FreeBSD Root-on-UFS sharing with Linux the same disk ( "Partioning" menu --> "Auto (UFS) Guided UFS Disk Setup" --> "Partition" menu --> "[ Partition ]" ), the ESP won't be overwritten by bsdinstall, only the FreeBSD efi loader will be copied to the existing ESP into a freebsd directory.

Question 2: UFS vs ZFS.
...
Linux can mount UFS read-only for rescue.
Linux can mount (import) a ZFS pool read-only as well, no reason to prefer UFS for rescue purposes. And one can always use a FreeBSD installer image "Live System" for rescue.

but the guided installer wants a whole disk and I’d have to build the pool by hand on a shared disk.
You can cut short the installation of a partial disk Root-on-ZFS with the script I attached to this post. Your unfamiliarity with ZFS administration may make you hesitant to proceed, but once you become familiar with it, you won't want to go back. I use exclusively ZFS.

In case you decide on ZFS:
  • Start the menu-guided installation, at the "Partioning" menu enter "Shell"
  • mount_msdosfs](8) efi partition
  • Make directory /EFI/freebsd, copy /boot/loader.efi.
  • gpart(8) add "freebsd-swap" , "freebsd-zfs", in any order you wish. Make sure swap is large enough for your use case.
  • run zfs-datasets.sh script [1]
  • exit "Shell"
  • proceed with the menu-guided system configuration, "Exit" "Final Configuration" menu, enter "< Yes >" at "Manual Configuration", edit /etc/fstab: add swap device, eventually add ESP partition
I recommend using ZFS not only on bare metal but also in a FreeBSD virtual machine. Work through the ZFS handbook chapters and test any planned ZFS operations in the VM before performing them on your bare-metal installation.

[1] The zfs-datasets.sh script is extracted from a menu-guided installation log (/var/log/bsdinstall_log), slightly modified. I use it in multi boot VM test environments. Copy script to the USB installer pen-drive, edit disk name and partition number (nda0p5), eventually add, remove datasets.

Code:
#!/bin/sh
#
# shell script created from /var/log/bsdinstall_log
#
# Creating root pool
zpool create -o ashift=12 -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot   nda0p5

# Creating ZFS datasets
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

# Setting mountpoint for root of the pool
zfs set mountpoint=/zroot zroot

# Modifying directory permissions
mkdir -p /mnt/tmp

chmod 1777 /mnt/tmp

mkdir -p /mnt/var/tmp

chmod 1777 /mnt/var/tmp

# Setting bootfs property
zpool set bootfs=zroot/ROOT/default zroot

# Configuring zpool.cache for zroot
mkdir -p /mnt/boot/zfs

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

# Set canmount=noauto for any datasets under the BE
zfs set canmount=noauto zroot/ROOT/default
 
Hey!

I had not heard of eEFInd before, looks like it's an alternative to Grub. I've been using Grub for years, I know how it works, I know how to use the Grub command line to boot kernels if my config gets borked, and perhaps most importantly, it is installed and working already. To be clear, I am not asking for help on how to configure Grub, or to configure the dual boot, I know how to do this already. My question may not have been clear, but I'm really just asking about how to ensure that my ESP does not get touched during the FreeBSD install.

i know you have no issue with grub but i suggested refind because it is much easier and atleast for me (better) for dualbooting so consider it , nothing bad about grub

also for zfs , maybe just try it , UFS is still here if you want it
 
Haha, OK guys. I'll be brave and try ZFS.

T-Daemon, you have made the process very clear for me, and the script is very helpful.

Thanks to both of you for the replies. I'll get to the install later today, or perhaps tomorrow, and report back on how it went.
 
Back
Top