I finally found a working method of installing FreeBSD 9.1-RELEASE using all ZFS, no UFS. It took me a bit of tinkering to come up with this script. I tried playing with the zpool cache file, etc., but only what I have here in this script ended up working for me.
The script shown below is specific to this particular server, it will need to be adjusted to suit the hardware. I put the script on a web server, then I boot the to be installed system from CD, select shell or Live CD. Then I download the script and execute. Tip: you can do that in one step
ftp -o - http://server/script.sh | sh
That will download the script and immediately execute it.
In this example the server has 6 disks. I’ve configured the hardware raid controller such that it is basically a JBOD. I want ZFS handling this, not hardware. While I would prefer ZFS have the entire disk, I don’t think that is possible today. I opted to make each disk identical from a layout perspective. My thinking being should a disk fail, any other disk should be bootable, etc.. I also opted to only create a raidz pool with 5 disks, the 6th disk is a spare. These are not the newest servers or drives, I know they will fail at some point and thus I’m willing to trade space for data protection.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #!/bin/sh MP=/mnt zpool export zroot for DSK in 0 1 2 3 4 5; do gpart destroy -F da$DSK gpart create -s gpt da$DSK gpart add -s 122 -t freebsd-boot da$DSK gpart add -s 512M -t freebsd-swap -l swap$DSK da$DSK gpart add -t freebsd-zfs -l disk$DSK da$DSK gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da$DSK done # Now create the pool zpool create -f -o altroot=$MP -O canmount=off zroot raidz /dev/gpt/disk0 /dev/gpt/disk1 /dev/gpt/disk2 /dev/gpt/disk3 /dev/gpt/disk4 spare /dev/gpt/disk5 # I personally dislike the root of pools being mounted and available. zfs set mountpoint=none zroot # Due to the above, we have to specify the mount points for each FS we create, # this same rule applies post install when we create a FS, must set the mount point zfs create -o mountpoint=/ zroot/ROOT zfs create -o mountpoint=/usr zroot/usr zfs create -o mountpoint=/var zroot/var zfs create -o setuid=off -o mountpoint=/home zroot/home zfs create -o setuid=off -o mountpoint=/usr/local zroot/usr/local zfs create -o exec=off -o setuid=off -o mountpoint=/usr/locall/etc/ zroot/usr/local/etc zfs create -o exec=off -o setuid=off -o mountpoint=/usr/src zroot/usr/src #zfs create -o setuid=off -o mountpoint=/usr/ports zroot/usr/ports #zfs create -o exec=off -o setuid=off -o mountpoint=/usr/ports/distfiles zroot/usr/ports/distfiles #zfs create -o exec=off -o setuid=off -o mountpoint=/usr/ports/packages zroot/usr/ports/packages zfs create -o exec=off -o setuid=off -o compression=on -o mountpoint=/var/crash zroot/var/crash zfs create -o exec=off -o setuid=off -o mountpoint=/var/db zroot/var/db zfs create -o exec=on -o setuid=off -o compression=on -o mountpoint=/var/db/pkg zroot/var/db/pkg zfs create -o exec=off -o setuid=off -o mountpoint=/var/empty zroot/var/empty zfs create -o exec=off -o setuid=off -o compression=on -o mountpoint=/var/log zroot/var/log zfs create -o exec=off -o setuid=off -o compression=on -o mountpoint=/var/mail zroot/var/mail zfs create -o exec=off -o setuid=off -o mountpoint=/var/run zroot/var/run zfs create -o exec=on -o setuid=off -o mountpoint=/var/tmp zroot/var/tmp cd /usr/freebsd-dist export DESTDIR=$MP/ echo "base..."; cat base.txz | tar --unlink -xpJf - -C ${DESTDIR:-/} echo "src..."; cat src.txz | tar --unlink -xpJf - -C ${DESTDIR:-/} echo "kernel..."; cat kernel.txz | tar --unlink -xpJf - -C ${DESTDIR:-/} echo "doc..."; cat doc.txz | tar --unlink -xpJf - -C ${DESTDIR:-/} #cat ports.txz | tar --unlink -xpJf - -C ${DESTDIR:-/} chmod 1777 $MP/tmp chmod 1777 $MP/var/tmp zfs set readonly=on zroot/var/empty zpool set bootfs=zroot/ROOT zroot cat > $MP/boot/loader.conf << __EOF__ zfs_load="YES" __EOF__ cat > $MP/etc/fstab << __EOF__ # 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 /dev/gpt/swap3 none swap sw 0 0 /dev/gpt/swap4 none swap sw 0 0 /dev/gpt/swap5 none swap sw 0 0 tmpfs /tmp tmpfs rw,mode=777 0 0 __EOF__ cat > $MP/etc/rc.conf << __EOF__ # General System Config # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable dumpdev="AUTO" zfs_enable="YES" clear_tmp_enable="YES" # Clear /tmp at startup ifconfig_em0="up" cloned_interfaces="vlan89" ifconfig_vlan4="inet 192.168.89.135 netmask 255.255.255.0 vlan 89 vlandev em0" ifconfig_vlan4_alias0="inet 192.168.89.245 netmask 255.255.255.255" defaultrouter="192.168.89.1" hostname="hostname.balius.com" sshd_enable="YES" __EOF__ zfs unmount -af ## The next two are "hacks" in my book, without the last line, on reboot ## it gets stuck trying to find zfs:zroot/ROOT, but somehow the -f "fixes" this quirk # zpool export zroot zpool import -f zroot echo "Now type reboot, remove CD-ROM, etc." |

