Painless FreeBSD server migration ================================= Some time ago the motherboard of one of my NUCs died. With some improvisation I got everything working again. However, this involved running 24/7 a machine that is loud and consumes quite some electrical power. This machine runs in our living room. Of course, this could only be a temporarily solution. Replacement network server -------------------------- Recently I got a "new" machine, to be used as a network server in my home network. This HP EliteDesk 800 G2 Mini dates probably from 2015, which make it around 8 or 9 years old. Some specs: * Intel Core i5-6500 * 8 Gb RAM * 256 Gb M.2 NVMe SSD To test it, I installed FreeBSD 14 on it, together with a few jails, as well as vm-bhyve, complete with a virtual machine running Debian. It ran stable, without any surprises, and I decided to set it up as a central server. New master jail --------------- Having a fresh FreeBSD machine with the latest stable version was a great occasion to start with a fresh master jail, also based on FreeBSD 14. This jail is kept untouched, as a basis for the other jails. The snapshot of this jail makes it easy to create new jails. IMAP- and STMP server --------------------- The first step was to recreate the IMAP- and STMP server. The previous IMAP- and STMP server was a jail, running an older FreeBSD version. Using zfs send and receive locally, I copied the master jail to a new jail, as starting point for the new IMAP and STMP server. The next step was to set up sendmail as STMP server, and Dovecot as IMAP server. The opendkim package makes it easy to setup DKIM. I copied the sendmail configuration, the opendkim configuration, and the keys for my domains from the previous server. After a restart sendmail and opendkim worked fine. I created a separate ZFS dataset for the Maildir and used mount_nullfs to mount this in the jail. This makes it possible to create snapshots of the Maildir, independent of snapshots of the whole jail. Migrating virtual machines -------------------------- The virtual machines on the existing machine are all created with vm-bhyve. The command "vm snapshot " creates a snapshot. The command set zfs send / zfs receive migrates the virtual machines to the new server and to the right location. The package vm-bhyve is easy to install and configure. All in all, the migration of the virtual machines went very smooth. Other jails ----------- I did set up some other jails, again starting with using a local zfs send / receive to copy the master jail. One of these jails runs some local webservices, like Bepasty. Again, in each jail the most dynamic part is on a separate ZFS dataset that is nullfs-mounted into the jail. All the jails are now based on FreeBSD 14. Snapshots --------- After finishing the setup of each jail, a snapshot of the jail was created. Every night a script creates a snapshot of each of the ZFS datasets containing a dynamic part in the jails. The script copies the snapshots using zfs send / zfs receive to another machine. Because of this, there is no need to frequently create new snapshots of the entire jails. Only after an upgrade or other change within the jail a new snapshot is needed. The virtual machines are mostly used for writing software reviews and for testing purposes. Depending on the task at hand, I use virtual machines with Debian, Ubuntu, FreeBSD, or OpenBSD. Immediately after the installation of the operating system I create a snapshot. Next, I can install packages, install software, and so on. When the review is finished or the testing is done, a simple roll back off the snapshot returns the virtual machine almost instantaneously to the pristine install. Creating a clone of a ZFS snapshot hardly takes any time. This is a great blessing when multiple machines with the same operating system are needed. Next steps ---------- Most work is done, There are some final parts to set up, like prose linting with Vale and Flycheck in the jail used for writing texts. The HP EliteDesk 800 G2 Mini has an empty slot for a 2.5 inch SSD. Currently the 256 Gb M.2 NVMe is sufficient. Perhaps in future I will replace it with a larger NVMe. For backup purposes, adding a 2.5 inch SSD is also an option. Considering the use of virtual machines, the amount of RAM will probably be the first bottleneck. The maximum RAM in this machine is 32 Gb (2 x 16 Gb SODIMM). I haven't check prices yet. FreeBSD on ZFS is wonderful --------------------------- Running FreeBSD, with jails and bhyve guests on ZFS is wonderful. ZFS snapshots are easy copied to another machine, either to recreate a jail, a virtual machine, or a data directory, or as a backup method. Last edited: $Date: 2024/02/05 21:38:25 $