I'm planning on setting up a new personal OpenBSD-current system by means of installing the latest OpenBSD snapshot, and I would want it to look more or less similar to my existing OpenBSD-current system in terms of local changes made to the files under /etc without actually copying the /etc directory over to the new system (it also contains configuration that the new system should not use, and other things that should be different).

What is the easiest way to compare my old setup with that of a pristine system so that I manually may go through and set up the new machine? I would like to compile a list of individual base system services etc. that I need to configure after installing the new OpenBSD system, just as a way of not accidentally leaving things out, like setting up a mail alias for root.


After upgrading my (old) system to the latest snapshot, a copy of the pristine /etc hierarchy (and also of other variable files under /root and /var) is available in /var/sysmerge/etc.tgz. There is also a separate archive called /var/sysmerge/xetc.tgz holding the base system's default X11 configuration. Note that etc.tgz does not contain files not intended to be modified, like /etc/services or /etc/daily, and that it does not contain configuration files for things that are installed without a default configuration file (but that may have one for local tweaking of the defaults), such as /etc/doas.conf.

To see what files I have modified on my old system, I may extract these archives to some directory and simply do a diff. The extraction has to be done as root as the /var/sysmerge directory is protected.

mkdir /tmp/tmpdir
doas tar -xz -f /var/sysmerge/etc.tgz -C /tmp/tmpdir
doas tar -xz -f /var/sysmerge/xetc.tgz -C /tmp/tmpdir

Looking at the diff is made easier by first deleting old unused configuration files belonging to packages no longer installed. These may be found by using the sysclean tool from ports. This tool would also identify old and unused versions of libraries, and it may be a good idea to run it after any system upgrade or after upgrading ports.

Producing a diff for the /etc files:

doas diff -ru /tmp/tmpdir/etc /etc

This produces a recursive unified diff of the files I'm likely to be interested in.

On my private system, this is enough to give me a hint of what I need to set up when I later get to configuring my new machine. For example, I had forgotten that I had disable root logins and password authentication in my /etc/ssh/sshd_config file, and that I at some point had set up an additional user for testing (!).

When done, I delete the unpacked archives:

doas rm -rf /tmp/tmpdir
  • mtree is definitely your friend for this sort of task. – JdeBP Feb 25 at 9:14
  • @JdeBP mtree will only show me differences in directory structures, not the actual differences in the files. – Kusalananda Feb 25 at 9:16
  • mtree compares digests, and will thus show one the files that differ in contents. There's even a check-what-files-have-changed example in its manual. – JdeBP Feb 25 at 9:23
  • @JdeBP Yes, I agree that this is a useful tool, but again, it won't show the differences in the files. It may well be that I don't know how to use it correctly. In that case I'd really appreciate if you submitted an answer. I know that files are different, but I also need to know in what way they are different. – Kusalananda Feb 25 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.