ZFS Install on Existing Pool and Different Dataset

I have a few ZFS related questions. I'm trying to set up a custom installation where instead of installing to a fresh ZFS pool, I would like to install using the auto ZFS install script; however, set the root of the ZFS install point to a sub dataset of an existing pool.

Say I had an existing pool with the dataset zroot/freebsd, I would like to have the installer use that as the top level point of the FreeBSD install. What would be the easiest way to do an install like this? Is there a way to do this with the installer without having to manually do the entire install?

Looking at the code from the BSD installer on GitHub I noticed that at the beginning of the script "zfsboot" it sets the pool name and a bunch of other settings. Would a good way to do an install like this be to customize this script to my liking and then run it in the installer somehow? How would you recommend I do this?

If I have to i'm fine with trying to do the install manually, but I would prefer to use the already completed script in the BSD install considering it should just be a small change to set it up in the way I would like to do it. I'm also afraid I might mess up the data sets if I were to try to do the whole thing myself as I noticed the dataset setup is fairly complicated.

Has anyone else done this? Or can anyone point to a resource where doing something like this is explained?
 
I haven't done it but it should be possible. Tools like sysutils/beadm actually use this to create separate environments. But you may need to install by hand though, I'm not sure if the installer is smart enough. I'd definitely try this on a test machine first.
 
I haven't done it but it should be possible. Tools like sysutils/beadm actually use this to create separate environments. But you may need to install by hand though, I'm not sure if the installer is smart enough. I'd definitely try this on a test machine first.
So I should be able to just run "zfsboot" from the shell in the installer? Then from there just use the installer as normal?
 
Actually, the installer really doesn't do much. It basically just untars the files in /usr/freebsd-dist. Which can easily be done by hand too.
 
If I have to i'm fine with trying to do the install manually, but I would prefer to use the already completed script in the BSD install considering it should just be a small change to set it up in the way I would like to do it.

I can't speak for the developers, but it seems to me that the automated ZFS install is really just a way to try out a pure ZFS install of FreeBSD before eventually manually setting up your own custom install. It's hard to imagine that many people are wholly satisfied with the results it provides.

You can achieve what you want with the installer, but the automatic ZFS install portion has nothing to do with it. The process for installing FreeBSD on a custom ZFS pool is always the same: at the "Partitioning" stage, select "Shell." You'll be dropped to a shell (surprise! :)) with a brief instruction at the top on what to do: create your partitions (or ZFS datasets) and mount them in the appropriate spots in /mnt. So you'd just import your existing ZFS pool---using /mnt as the "altroot" for it---and create your new datasets for the new install with the appropriate mountpoints. Double-check that the clean datasets are mounted in the right place relative to what the final result would be, and exit the shell. The installer will proceed as usual, installing a clean system to your new datasets/boot environment. You'd then edit /etc/rc.conf, /boot/loader.conf, and (if necessary) /etc/fstab to get it to boot. You can look over this guide as one example of the results you can get with that method.

A slightly more advanced method would be to clone your existing base system datasets rather than manually creating new ones, which (I'm guessing) is what sysutils/beadm does, and is what you would manually do when using a separate boot environment to test an upgrade.
 
Back
Top