mount -rw /
Fixit# gpart create -s gpt ad0
If the disk already contains a partitioning scheme, and this scheme would first need to be destroyed using:
Fixit# gpart destroy ad0
Fixit# gpart add -s 64K -t freebsd-boot ad0 Fixit# gpart add -s 4G -t freebsd-swap -l swap0 ad0 Fixit# gpart add -t freebsd-zfs -l disk0 ad0
This creates 3 partitions. The first partition will contains the gptzfsboot loader which will be able to load /boot/loader or /boot/zfsloader (9.0-CURRENT) from a ZFS partition. The second partition is a 4 GB swap partition. The third partition is dedicated to the ZFS zpool and uses the remaining space on the disk.
Fixit# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad0
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:
Fixit# sysctl kern.geom.debugflags=0x10
Fixit# kldload opensolaris.ko Fixit# kldload zfs.ko
Fixit# zpool create zroot /dev/gpt/disk0 Fixit# zpool set bootfs=zroot zroot
zroot is the name of the ZFS Pool, it could be anything (i.e. tank, data, …)
The fletcher4 algorithm should be more robust than the fletcher2 algorithm.
Fixit# zfs set checksum=fletcher4 zroot
Fixit# zfs create -o compression=on -o exec=on -o setuid=off zroot/tmp Fixit# chmod 1777 /zroot/tmp
Fixit# zfs create zroot/usr Fixit# zfs create zroot/usr/home Fixit# cd /zroot ; ln -s /usr/home home
Fixit# zfs create -o compression=lzjb -o setuid=off zroot/usr/ports Fixit# zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/distfiles Fixit# zfs create -o compression=off -o exec=off -o setuid=off zroot/usr/ports/packages
If you use nullfs or nfs to mount /usr/ports to different locations/servers, you will also need to nullfs/nfs mount /usr/ports/distfiles and/or /usr/ports/packages.
Fixit# zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/usr/src
Fixit# zfs create zroot/var Fixit# zfs create -o exec=off -o setuid=off zroot/var/db Fixit# zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/db/pkg Fixit# zfs create -o exec=off -o setuid=off zroot/var/empty Fixit# zfs create -o compression=lzjb -o exec=off -o setuid=off zroot/var/log Fixit# zfs create -o compression=lzjb -o exec=on -o setuid=off zroot/var/tmp Fixit# chmod 1777 /zroot/var/tmp
zfs set mountpoint=/mnt zroot zfs set mountpoint=/mnt/tmp zroot/tmp zfs set mountpoint=/mnt/usr zroot/usr zfs set mountpoint=/mnt/var zroot/var zfs mount -a
exit
Fixit# zfs set readonly=on zroot/var/empty
Fixit# chroot /mnt
Fixit# echo 'zfs_enable="YES"' >> /etc/rc.conf
Fixit# echo 'zfs_load="YES"' > /boot/loader.conf Fixit# echo 'vfs.root.mountfrom="zfs:zroot"' >> /boot/loader.conf
Fixit# exit
Fixit# cp /boot/zfs/zpool.cache /boot/zfs/zpool.cache
Fixit# cat << EOF > /mnt/etc/fstab # Device Mountpoint FStype Options Dump Pass# /dev/gpt/swap0 none swap sw 0 0 EOF
Fixit# zfs unmount -a
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