ZFS How to install a ZFS based system using an existing system

How would I go about installing a zfs based system on a different partition using an existing system?

Do I first add a freebsd-zfs partition?

I want to install it manually. I'm hoping I will be able to boot via Ventoy.
 
How would I go about installing a zfs based system on a different partition using an existing system?

Do I first add a freebsd-zfs partition?

I want to install it manually. I'm hoping I will be able to boot via Ventoy.

Don't know if this could help. It's how I dual boot 14 and 15 on an old laptop with UEFI and zfs.

/grandpa
 
The point of using ZFS is redundancy. ZFS is designed to keep your data safe. the design philosophy is to use TWO physical storage devices and mirror them.
Then the ZFS SCRUB function that compares the data on the two physical drives to check for corruption on one of the drives can be used as planned and prevent
your files to suffer from bit-rot. If your ZFS filesystem only exist on a single storage device, this functionality is not usable.
Of course you can use the snapshots , compression , encryption a.s.o. features , but the data redundancy cant be achieved with a single disk.
Most Laptops i have encountered can be equipped with DUAL identical M.2 NVME sticks these days,
then the best strategy is to Install FreeBSD over both Storage devices as a Mirrored ZPOOL.
 
On Ventoy I have a ventoy_grub.cfg which I use for loading all my FreeBSD partitions which has entries like this for every installation. I just need to adjust the set root line.

sh:
menuentry "FreeBSD 15.0 - Main (P3) " --class=custom {
    echo 'Booting FreeBSD 15.0 via Ventoy...'
    insmod ufs2
    insmod part_gpt
    set root=(hd0,gpt3)
    kfreebsd /boot/loader
}

Obviously the insmod ufs2 line won't apply if I'm booting a ZFS partition. I tried entering insmod zfs but there is no such module.

Just wondered if anyone had managed to boot a ZFS partition frrom Ventoy.
 
It looks as though I need to create two extra partitions, efi and freebsd-boot.
Does that sound correct.

My existing FreeBSD partitions do not require a freebsd-boot partition, Ventoy loads /boot/loader directly.
 
Code:
insmod part_gpt
insmod zfs
insmod bsd
search --no-floppy --set=root --label zroot
kfreebsd /@/boot/zfsloader
kfreebsd_loadenv /@/boot/device.hints
zfs:zroot/ROOT/default
 
If above works not.
In theory,
- Ventory will read grub.cfg
- Look for disk having zpool named zpool : "search --no-floppy --set=root --label zroot"
- Load freebsd kernel from this zpool on that disk : "kfreebsd /@/boot/zfsloader"
- And tell kernel boot , which root filesystem it should mount : "zfs:zroot/ROOT/default"

If for some reason it fails, then you revert to other solutions.
 
If above works not.
In theory,
- Ventory will read grub.cfg
- Look for disk having zpool named zpool : "search --no-floppy --set=root --label zroot"
- Load freebsd kernel from this zpool on that disk : "kfreebsd /@/boot/zfsloader"
- And tell kernel boot , which root filesystem it should mount : "zfs:zroot/ROOT/default"

If for some reason it fails, then you revert to other solutions.
Do I enter all this literally?

Presumably I should add this to /dev/ada0p1/ventoy/ventoy_grub.cfg

I don't see any reference to which partition should be checked.
 
Can I use this script to create a ZFS filesystem on a partition?


I would be booting FreeBSD from a different partition so I'd like to know if I can run this from script from that partitiion. It isn't immediately obvious where it is being run from.

Do I mount that partition on /mnt, cd /mnt and then run the script?
 
that script creates a ZROOT pool with all requied ZFS filesystems,

To create a ZFS POOL and Filesystem on a blank storage device do:

# zpool create newpool devicename
# zfs create newpool/filesystemname


then you can set options on the pool and filesystem with

# zpool set ........... newpool
# zfs set ........ newpool/filesystem

study manual pages zpool-get and zfs-get
 
Can I use this script to create a ZFS filesystem on a partition?
That script is ancient:

"shigeyas/setup-zfs-root-filesystem.sh Created 14 years ago"

It creates zroot/usr/home datasets. The official installer creates zroot/home for some time now.

Use the script down below. It is extracted from a 15.0-RELEASE bsdinstaller_log.

Save it on the iso (bsdinstall(8), see BUILDING AUTOMATIC INSTALL MEDIA), and copy during installation to /tmp to edit, or fetch it during install from LAN into /tmp of installer media. /tmp and /var are the only writable directories when booting the iso.

Boot installer media, start menu guided installation, at the "Partitioning" menu enter "Shell", create manual GPT scheme and partitions (ESP- efi, freebsd-swap, freebsd-zfs), create ESP, copy loader.efi, execute ZFS pool-dataset creator script, exit "Shell", continue with installation. At the end check /boot/loader.conf, /etc/fstab, /etc/rc.conf, /etc/sysctl.conf.

Make sure to get the device name right.
Code:
#!/bin/sh
#
# shell script extracted from /var/log/bsdinstall_log
# Creating root pool

# Replace "ada0pX" with actual device name

 zpool create -o ashift=12 -o altroot=/mnt -O compress=lz4 -O atime=off -m none -f zroot   ada0pX

# 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
 
that script creates a ZROOT pool with all requied ZFS filesystems,

To create a ZFS POOL and Filesystem on a blank storage device do:

# zpool create newpool devicename
# zfs create newpool/filesystemname

Does blank storage device include a new partition on an existing disk which includes other bootable OSes?
 
Back
Top