root@OPNsense:/ # zfs list -t allNAME USED AVAIL REFER MOUNTPOINTzroot 904M 48.5G 88K /zrootzroot/ROOT 900M 48.5G 88K nonezroot/ROOT/default 900M 48.5G 900M /zroot/tmp 152K 48.5G 152K /tmpzroot/usr 352K 48.5G 88K /usrzroot/usr/home 88K 48.5G 88K /usr/homezroot/usr/ports 88K 48.5G 88K /usr/portszroot/usr/src 88K 48.5G 88K /usr/srczroot/var 1.36M 48.5G 88K /varzroot/var/audit 88K 48.5G 88K /var/auditzroot/var/crash 88K 48.5G 88K /var/crashzroot/var/log 956K 48.5G 956K /var/logzroot/var/mail 88K 48.5G 88K /var/mailzroot/var/tmp 88K 48.5G 88K /var/tmproot@OPNsense:/ # echo "test1" > test.txtroot@OPNsense:/ # cat test.txttest1root@OPNsense:/ # zfs snap -r zroot@snap1root@OPNsense:/ # echo "test2" > test.txtroot@OPNsense:/ # cat test.txttest2root@OPNsense:/ # zfs list -t allNAME USED AVAIL REFER MOUNTPOINTzroot 904M 48.5G 88K /zrootzroot@snap1 0 - 88K -zroot/ROOT 900M 48.5G 88K nonezroot/ROOT@snap1 0 - 88K -zroot/ROOT/default 900M 48.5G 900M /zroot/ROOT/default@snap1 56K - 900M -zroot/tmp 152K 48.5G 152K /tmpzroot/tmp@snap1 0 - 152K -zroot/usr 352K 48.5G 88K /usrzroot/usr@snap1 0 - 88K -zroot/usr/home 88K 48.5G 88K /usr/homezroot/usr/home@snap1 0 - 88K -zroot/usr/ports 88K 48.5G 88K /usr/portszroot/usr/ports@snap1 0 - 88K -zroot/usr/src 88K 48.5G 88K /usr/srczroot/usr/src@snap1 0 - 88K -zroot/var 1.43M 48.5G 88K /varzroot/var@snap1 0 - 88K -zroot/var/audit 88K 48.5G 88K /var/auditzroot/var/audit@snap1 0 - 88K -zroot/var/crash 88K 48.5G 88K /var/crashzroot/var/crash@snap1 0 - 88K -zroot/var/log 1.00M 48.5G 956K /var/logzroot/var/log@snap1 72K - 956K -zroot/var/mail 88K 48.5G 88K /var/mailzroot/var/mail@snap1 0 - 88K -zroot/var/tmp 88K 48.5G 88K /var/tmpzroot/var/tmp@snap1 0 - 88K -root@OPNsense:/ # zfs rollback -r zroot@snap1root@OPNsense:/ # cat test.txttest2
zfs list -t snap -h | awk '/@snap1/ { printf "zfs rollback %s\n", $1 }' | sh
# list current BEsbectl list# assume we are running 21.7 and the major update to 22.1 is waiting# rename "default" to "21.7"bectl rename default 21.7# create new BE for the new versionbectl create 22.1# activate new BE for next reboot, then reboot into itbectl activate 22.1reboot# now perform UI update# after reboot 2 BEs will be present: 21.7 and 22.1 - you can pick them at the boot loader prompt if necessarybectl list
But ...you might want to look into boot environments. They take care of the snapshots and allow you to give fancy names to your various versions, even boot into past ones if you have console access.Code: [Select]# list current BEsbectl list# assume we are running 21.7 and the major update to 22.1 is waiting# rename "default" to "21.7"bectl rename default 21.7# create new BE for the new versionbectl create 22.1# activate new BE for next reboot, then reboot into itbectl activate 22.1reboot# now perform UI update# after reboot 2 BEs will be present: 21.7 and 22.1 - you can pick them at the boot loader prompt if necessarybectl listYou can do the same with minor versions, of course. All the work is already been done. Enjoy
Holy crapperjacks that's awesome! Was bectl made by/for OPNSense or is this a FreeBSD tool that I have yet to come across? Well done whoever made it, like a cross between installing a new Linux kernel and making a VM snapshot, hah!
Is it worth to build a plugin around it? @pmhausen: is there a way to define a fallback if Default doesnt boot?
bectl create new-versionbectl activate -t new-version # only activates for one bootshutdown -r now# do updatebectl activate -t new-versionshutdown -r now# check if it works, if ok, thenbectl activate new-version # activate permanently
I wonder if the -r flag is needed to be able to go back to a previous system version.eg bectl create -r 22.1
In general - no. The dataset layout of FreeBSD on ZFS is carefully tailored so that everything impacted by an update is in one single dataset - the boot environment.Things like users' home directories and all of /var/* are excluded, because they might contain valuable continuously changing application data that you want to keep even in case you do a rollback of an update gone wrong.