Sysadmin > FreeBSD > BootEnvironmentsOnFreeBSD > SettingUpSolarisLikeBootEnvironmentsOnFreeBSD

Setting up Solaris-like boot environments on FreeBSD

This is a interesting page only available form google cache:

There is a set of outdated instructions. You should use this instead.

Boot environments are both OS and ZFS feature that allow for Solaris to boot from multiple ZFS pools. Having a previous boot environment available has helped me to recover from a bad mistake in the current boot environment at least once. Also, if you want to test svn /projects/, you can do so in different boot environments.

To use boot environments in FreeBSD, do the following in sh: Adjust this to your setup (be careful). Keep a live cd/usb handy just in case.


zfs snapshot -r rpool@snap0
zfs create -o dedup=on rpool/ROOT
zfs send rpool@snap0 | zfs recv rpool/ROOT/base-be
zfs destroy rpool/ROOT/base-be@snap0
zfs destroy rpool@snap0
zfs list -t snapshot -H -o name | while read s; do zfs send $s | zfs recv `echo $s|sed 's/rpool\/\(.*\)@snap0$/rpool\/ROOT\/base-be\/\1/g'`; done
zfs list -t snapshot -H -o name | grep snap0 | xargs -n1 zfs destroy
zfs set freebsd:boot-environment=1 rpool/ROOT/base-be
zfs list -H -o name | xargs -n1 zfs set canmount=noauto
zfs set mountpoint=/mnt rpool/ROOT/base-be
zfs mount rpool/ROOT/base-be
#edit /mnt/boot/loader.conf and change bootloader to boot from rpool/ROOT/base-be
zfs set mountpoint=/ rpool/ROOT/base-be
zfs list -H -o name | grep ROOT/base-be/ | while read f; do zfs set mountpoint=`echo $f | sed 's/rpool\/ROOT\/base-be//g'` $f; done
zpool set bootfs=rpool/ROOT/base-be rpool
#reboot now
#change mountpoints for your old pool and destroy data as needed
zfs list | grep rpool/ | grep -v ROOT | xargs -n1 zfs destroy
zfs set mountpoint=/mnt rpool
chflags -R 0 /mnt/*
rm -rf /mnt/*
zfs set mountpoint=none pool


I would recommend scripting this. You can find maintenance description here.