Support #765
Updated by Daniel Curtis almost 9 years ago
This is a guide on how I manually setup FreeBSD with a ZFS root on a GPT formatted hard drive, without the help of a GUI or bsdinstall. This guide is intended to install FreeBSD using the installation DVD and will work offline. * When the FreeBSD Installer Welcome message appears, choose *Shell*. * Get a list of available drives: <pre> camcontrol devlist </pre> * Create the GPT slices: <pre> gpart create -s gpt ada0 </pre> *# Then create the boot slice: <pre> gpart add -b 40 -s 512K -t freebsd-boot -a 4k -l boot0 -t freebsd-boot ada0 </pre> *# Create the swap slice: <pre> gpart add -s 4G -t freebsd-swap -a 4k -l swap0 ada0 </pre> *# Then create the root ZFS slice: <pre> gpart add -t freebsd-zfs -a 4k -l disk0 ada0 </pre> * Create ZFS pool using the GPT disk labeled @disk0@, and root dataset, then export it: <pre> zpool create -o altroot=/mnt -o cachefile=/tmp/zpool.cache -m / -f rpool /dev/gpt/disk0 zpool export rpool </pre> * Next import the ZFS pool using @/mnt@ as the alternate root create the root dataset datasets and settings: <pre> zpool import -o altroot=/mnt -o cachefile=/tmp/zpool.cache rpool zpool set bootfs=rpool rpool zfs set checksum=fletcher4 rpool zfs set atime=off rpool zfs create rpool/root </pre> #* Then create some additional system datasets: <pre> zfs create -o canmount=off rpool/root/usr zfs create -o canmount=off rpool/root/var zfs create -o compression=on -o exec=on -o setuid=off rpool/root/tmp zfs create -o compression=gzip -o setuid=off rpool/root/usr/ports zfs create -o compression=off -o exec=off -o setuid=off rpool/root/usr/ports/distfiles zfs create -o compression=off -o exec=off -o setuid=off rpool/root/usr/ports/packages zfs create -o compression=gzip -o exec=off -o setuid=off rpool/root/usr/src zfs create -o compression=lzjb rpool/root/usr/obj zfs create -o compression=lzjb -o exec=off -o setuid=off rpool/root/var/crash zfs create -o compression=off -o exec=off -o setuid=off rpool/root/var/empty zfs create -o compression=lzjb -o exec=on -o setuid=off rpool/root/var/tmp </pre> * Set the permissions of the temp directories in the zfs mount: <pre> chmod 1777 /mnt/tmp chmod 1777 /mnt/var/tmp </pre> * Extract the base.txz and kernel.txz to the zfs root to install the base system: <pre> cat /usr/freebsd-dist/base.txz | tar --unlink -xpJf - -C /mnt cat /usr/freebsd-dist/kernel.txz | tar --unlink -xpJf - -C /mnt </pre> * Add the initial system configuration: <pre> echo 'zfs_enable="YES"' >> /mnt/etc/rc.conf echo 'sshd_enable="YES"' >> /mnt/etc/rc.conf touch /mnt/etc/fstab </pre> #* And setup networking using DHCP: <pre> echo 'ifconfig_em0="DHCP"' >> /mnt/etc/rc.conf echo 'hostname="freebsd.example.com"' >> /mnt/etc/rc.conf </pre> #* (Optional) Setup networking using a static IP address instead: <pre> echo 'ifconfig_em0="inet 192.168.10.70 netmask 255.255.255.0 broadcast 198.100.10.255"' >> /mnt/etc/rc.conf echo 'defaultrouter="192.168.10.1"' >> /mnt/etc/rc.conf echo 'hostname="freebsd.example.com"' >> /mnt/etc/rc.conf echo 'nameserver 192.168.10.1' >> /mnt/etc/resolv.conf touch /mnt/etc/fstab </pre> * Install the bootcode and set the boot partion to active: <pre> gpart bootcode -b /mnt/boot/pmbr -p /mnt/boot/gptzfsboot -i 1 ada0 gpart set -a bootme -i 1 ada0 </pre> * Add the bootloader config: <pre> echo 'zfs_load="YES"' >> /mnt/boot/loader.conf echo 'if_em_load="YES"' >> /mnt/boot/loader.conf echo 'vfs.root.mountfrom="zfs:rpool"' >> /mnt/boot/loader.conf </pre> * Copy the working zpool.cache file to the rpool: <pre> cp /tmp/zpool.cache /mnt/boot/zfs/zpool.cache </pre> * Unmount the zpool: <pre> zpool export rpool </pre> * Reboot the system and eject the FreeBSD install disc: <pre> reboot </pre> h2. Resources * https://forums.freebsd.org/threads/42773/ * https://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE * https://calomel.org/zfs_freebsd_root_install.html * http://daemon-notes.com/articles/system/install-zfs/gpart * http://daemon-notes.com/articles/system/install-zfs/zfs * http://daemon-notes.com/articles/system/install-zfs/finish