HOWTO: FreeBSD ZFS Madness (Boot Environments)

Randal L. Schwartz merlyn at
Sat May 5 13:41:29 UTC 2012

>>>>> "vermaden" == vermaden  <vermaden at> writes:

vermaden> To the point, check these two code snippets, they should
vermaden> do EXACLY the same, logic is the same, the differece is
vermaden> only the syntax.

vermaden> snippet 1:

vermaden>         [ ${MOUNT} -eq 0 ] && {
vermaden>           zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
vermaden>           zfs mount ${POOL}/ROOT/${2}
vermaden>         } || {
vermaden>           TMPMNT=${MOUNT}
vermaden>         }

vermaden> snippet 2:

vermaden>         if [ ${MOUNT} -eq 0 ]; then
vermaden>           zfs set mountpoint=${TMPMNT} ${POOL}/ROOT/${2}
vermaden>           zfs mount ${POOL}/ROOT/${2}
vermaden>         else
vermaden>           TMPMNT=${MOUNT}
vermaden>         fi

No, no and no.  I got burned by that about 30 years ago in shell
programming.  Every time I see someone use that, I shriek just a little

vermaden> ... or to rewrite it under if/then/else which I did for the whole
vermaden> *beadm* utility and I no longer use || and && syntax,
vermaden> anywhere.

Good to see you've finally been burned.  You'll never make that mistake
again. :)

vermaden> After reboot ...

vermaden> # zfs destroy -R zroot/ROOT
vermaden> # zfs create -o mountpoint=none zroot/ROOT
vermaden> # zfs send zpool at be | zfs recv zroot/ROOT/be
vermaden> # fetch
vermaden> # chmod +x beadm
vermaden> # ./beadm list
vermaden> # ./beadm activate be
vermaden> # reboot

vermaden> Now You should have a working system with boot environments.

OK, I'll give that a try. Thanks for being persistent with me.

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at> <URL:>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See for Smalltalk discussion

More information about the freebsd-questions mailing list