zfsboot support if currently only available in FreeBSD current as of late November 2008. So currently you need an already up-to-date FreeBSD CURRENT machine to install a FreeBSD with zfsroot on another disk. Before building an up-to-date FreeBSD kernel and world, you have to set LOADER_ZFS_SUPPORT=yes in make.conf After that its time for the step-by-step run-down. Please read the run-down first, try to understand what you are doing and then do it step-by-step or use the appended example script. # Create a GPT label on your disc gpart create -s gpt ad4 # Add a FreeBSD boot-partition which will hold the ZFS bootcode % gpart add -b 34 -s 128 -t freebsd-boot ad4 # Too see how much space is left on your disc use % gpart show ad4 => 34 586114637 ad4 GPT (29G) 34 128 1 freebsd-boot (64K) 162 60313308 - free - (29G) # As you can see there are 29GB free space left. # Add a FreeBSD zfs-partition which will be the provider of your zpool % gpart add -b 162 -s 60313308 -t freebsd-zfs ad4 # Add the GPT bootcode to the MBR and add the ZFS bootcode to the freebsd-boot partition gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad4 # To make sure the BIOS loads the MBR of the disc use fdisk to activate the first slice % fdisk -a /dev/ad4 # Now we can create the zpool on the freebsd-zfs partition % zpool create mypool ad4p2 # Your pool should now be mounted under /mypool # Create the filesystem used for holding your freebsd-system % zfs create -p mypool/ROOT/freebsd # Now we create some we also would like to have in seperate filesystems % zfs create -o mounted=no,mountpoint=/usr/local mypool/usr-local % zfs create -o mounted=no,mountpoint=/tmp mypool/tmp % zfs create mypool/var # Now its time to install FreeBSD % cd /usr/src % make -s installkernel DESTDIR=/mypool/ROOT/freebsd/ % make -s installworld DESTDIR=/mypool/ROOT/freebsd/ % mergemaster -i -D /mypool/ROOT/freebsd/ # We need to fix /var so it is mounted correct when booting from ZFS % zfs umount mypool/var % zfs set mountpoint=/var mypool/var # Enable the new filesystem as zpool bootfs % zpool set bootfs=mypool/ROOT/freebsd mypool # We still need to tell the kernel from where to mount its root-filesystem # Add zfs_load="YES" to /mypool/ROOT/freebsd/boot/loader.conf # Add vfs.root.mountfrom="zfs:mypool/ROOT/freebsd" to /mypool/ROOT/freebsd/boot/loader.conf # Copy the zpool.cache to the new filesystem % cp /boot/zfs/zpool.cache /mypool/ROOT/freebsd/boot/zfs/zpool.cache # Thats it, you should now be able to boot into ZFS-root is you set your bios to boot from ad4 ################ EXAMPLE SCRIPT ################### #!/bin/sh pool=$1 geom=$2 swapsize=$3 if [ "$pool" = "" ] || [ "$geom" = "" ]; then echo 'Usage (swapsize)' exit fi swapsize=`echo "${swapsize}"|tr GMKBWX gmkbwx|sed -Ees:g:km:g -es:m:kk:g -es:k:"*2b":g -es:b:"*128w":g -es:w:"*4 ":g -e"s:(^|[^0-9])0x:\1\0X:g" -ey:x:"*":|bc |sed "s:\.[0-9]*$::g"` swapsize=`echo "${swapsize}/512" |bc` gpart create -s gpt $geom gpart add -b 34 -s 128 -t freebsd-boot $geom gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $geom if [ "$swapsize" ]; then offset=`gpart show $geom | grep '\- free \-' | awk '{print $1}'` gpart add -b $offset -s $swapsize -t freebsd-swap $geom partnum=`gpart show $geom | grep 'freebsd\-swap' |awk '{print $3}'` glabel create swap /dev/${geom}p${partnum} fi offset=`gpart show $geom | grep '\- free \-' | awk '{print $1}'` size=`gpart show $geom | grep '\- free \-' | awk '{print $2}'` gpart add -b $offset -s $size -t freebsd-zfs $geom partnum=`gpart show $geom | grep 'freebsd\-zfs' |awk '{print $3}'` # Make first partition active so the BIOS boots from it echo 'a 1' | fdisk -f - $geom # Create the pool and the rootfs zpool create $pool ${geom}p${partnum} zfs create -o compression=lzjb -p $pool/ROOT/$pool # Now we create some stuff we also would like to have in seperate filesystems for filesystem in var usr-local tmp; do echo "Creating $pool/$filesystem" zfs create $pool/$filesystem zfs umount $pool/$filesystem _filesystem=`echo $filesystem | sed s:-:\/:g` zfs set mountpoint=/${_filesystem} $pool/${filesystem} done zfs set mountpoint=/$pool/ROOT/$pool/var $pool/var zfs mount $pool/var echo #################################### echo 'Now install world, kernel etc' cd /usr/src make -s installkernel DESTDIR=/$pool/ROOT/$pool/ make -s installworld DESTDIR=/$pool/ROOT/$pool/ mergemaster -i -D /$pool/ROOT/$pool/ chmod 1777 /$pool/ROOT/$pool/tmp chmod 1777 /$pool/ROOT/$pool/var/tmp # We need to fix /var so it is mounted correct when booting from ZFS zfs umount $pool/var zfs set mountpoint=/var $pool/var # Enable the new filesystem as zpool bootfs zpool set bootfs=$pool/ROOT/$pool $pool # We still need to tell the kernel from where to mount its root-filesystem echo 'zfs_load="YES"' >> /$pool/ROOT/$pool/boot/loader.conf echo "vfs.root.mountfrom=\"zfs:$pool/ROOT/$pool\"" >> /$pool/ROOT/$pool/boot/loader.conf echo 'zfs_enable="YES"' >> /$pool/ROOT/$pool/etc/rc.conf if [ "$swapsize" ]; then echo 'geom_label_load="YES"' >> /$pool/ROOT/$pool/boot/loader.conf echo "/dev/label/swap none swap sw 0 0" > /$pool/ROOT/$pool/etc/fstab fi # Copy the zpool.cache to the new filesystem cp /boot/zfs/zpool.cache /$pool/ROOT/$pool/boot/zfs/zpool.cache