Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Installing FreeBSD Root on ZFS (RAIDZ2) using GPT ====== ===== Creating a bootable ZFS Filesystem ===== - Boot %%FreeBSD%% install DVD or USB Memstick - Choose Fixit option in sysinstall - Create GPT Disks <code> Fixit# gpart create -s gpt ad0 Fixit# gpart create -s gpt ad1 Fixit# gpart create -s gpt ad2 </code> - Create the boot, swap and zfs partitions Create 3 partitions on drives ad0, ad1 and ad2. The first partition contains the gptzfsboot loader which is able to recognize and load the loader from a [[/ZFS]] partition. The second partition is a 4 GB swap partition. The third partition is the partition containing the zpool (60GB). <code> Fixit# gpart add -b 34 -s 128k -t freebsd-boot ad0 Fixit# gpart add -s 4G -t freebsd-swap -l swap0 ad0 Fixit# gpart add -s 60G -t freebsd-zfs -l disk0 ad0 </code> <code> Fixit# gpart add -b 34 -s 128k -t freebsd-boot ad1 Fixit# gpart add -s 4G -t freebsd-swap -l swap1 ad1 Fixit# gpart add -s 60G -t freebsd-zfs -l disk1 ad1 </code> <code> Fixit# gpart add -b 34 -s 128k -t freebsd-boot ad2 Fixit# gpart add -s 4G -t freebsd-swap -l swap2 ad2 Fixit# gpart add -s 60G -t freebsd-zfs -l disk2 ad2 </code> <callout type="info"> **Note:** - While a [[/RootOnZFS#ZFS_Swap_Volume|ZFS Swap Volume]] can be used instead of the freebsd-swap partition, crash dumps can't be created on the ZFS Swap Volume. - Sizes and offsets are specified in sectors (1 sector is typically 512 bytes) but can also be specified in MB/GB by adding an 'M' or 'G' suffix. </callout> - Install the Protective MBR (pmbr) and gptzfsboot loader to all three drives <code> Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad0 Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad1 Fixit# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ad2 </code> This may fail with an "operation not permitted" error message, since the kernel likes to protect critical parts of the disk. If this happens for you, run: <code> Fixit# sysctl kern.geom.debugflags=0x10 </code> - Load ZFS kernel module <code> Fixit# kldload /mnt2/boot/kernel/opensolaris.ko Fixit# kldload /mnt2/boot/kernel/zfs.ko </code> - Create ZFS Pool zroot <code> Fixit# mkdir /boot/zfs Fixit# zpool create zroot raidz2 /dev/gpt/disk0 /dev/gpt/disk1 /dev/gpt/disk2 Fixit# zpool set bootfs=zroot zroot </code> <callout type="info"> **Note:** zroot is the name of the ZFS Pool, it could be anything (i.e. tank, data, ...) </callout> ===== Installing FreeBSD to the ZFS filesystem ===== {{page>RootOnZFS/InstallingFreeBSD&nofooter&noeditbtn}} ===== Finish install ===== - Create /etc/fstab <code> Fixit# cat << EOF > /zroot/etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/gpt/swap0 none swap sw 0 0 /dev/gpt/swap1 none swap sw 0 0 /dev/gpt/swap2 none swap sw 0 0 EOF </code> - export LD_LIBRARY_PATH <code> Fixit# export LD_LIBRARY_PATH=/mnt2/lib </code> - Unmount all zfs filesystems <code> Fixit# zfs unmount -a </code> - Change mount points for zroot pool <code> Fixit# zfs set mountpoint=legacy zroot Fixit# zfs set mountpoint=/tmp zroot/tmp Fixit# zfs set mountpoint=/usr zroot/usr Fixit# zfs set mountpoint=/var zroot/var </code> - Exit Fixit mode, and then sysinstall. Remove the %%FreeBSD%% install DVD/Memstick and the system will boot using the ZFS root. rootonzfs/gptzfsboot/raidz2.txt Last modified: 2016/10/27 20:29by LiWenHsu