3 days ago
I don't know how much interest in this there really is going to be around here, since it's a program written in D rather than a library for D programmers to use, but it _is_ written in D, so I'm posting about it here.

bemgr is a program that I wrote to manage ZFS boot environments. It's similar to beadm and bectl on FreeBSD, but they don't work on Linux, and while my primary machine is running FreeBSD, I do have Linux machines using ZFS on root. So, I wrote a solution in D and made it work on both FreeBSD and Linux.

The primary differences between beadm and bectl and bemgr are that

1. "bemgr list" has the "Referenced" and "If Last" columns, whereas beadm
   and bectl do not - though they have the -D flag which causes the "Space"
   column to be similar to "If Last".

2. "bemgr destroy" destroys origins by default and has -n do do a dry-run,
   whereas "beadm destroy" asks before destroying origins, and
   "bectl destroy" does not destroy origins by default. And neither
   "beadm destroy" nor "bectl destroy" has a way to do dry-runs.

3. bemgr has no equivalent to "beadm chroot" or "bectl jail".

I consider bemgr 1.0.0 to be feature-complete, and there are no known bugs (though obviously, that doesn't necessarily mean that there are no bugs).

The repo and its documentation: https://github.com/jmdavis/bemgr The release: https://github.com/jmdavis/bemgr/releases/tag/v1.0.0

There is also a man page for documentation (and man is the syntax for
writing those ugly).

I have included packages for Debian and Arch as well as prebuilt tarballs with an install script for both FreeBSD and Linux (which allow you to provide an install prefix). bemgr has been tested on FreeBSD, Debian, and Arch, though presumably, it'll work on pretty much any Linux distro as long as you're using a boot manager that supports ZFS boot environments (I'd recommend zfsbootmenu).

Interestingly enough, dmd 1.111.0 saw a significant performance improvement on FreeBSD (e.g. "bemgr list" went from about 0.5 seconds to about 0.07 seconds) due to executeShell becoming much faster for some reason (and from what little testing I did of commits, it doesn't appear to be from any changes to std.process). So, because ldc hasn't released a version based on 1.111.0 yet, the FreeBSD build was done with dmd, since executeShell was much faster with dmd even though most of the rest of the D code was faster with ldc, and the vast majority of the time spent by bemgr is in the zfs commands that it's triggering with executeShell.

>From what I've seen on Linux, it didn't matter whether dmd 1.110.0 or dmd
1.111.0 was used, so those binaries are built with ldc (they both were in the 0.11 seconds range with "bemgr list"). Likely due to some differences with ZFS on Linux, the FreeBSD version is faster in general, but it's not like the Linux version is all that slow. It just isn't as fast as the FreeBSD version, and since it's the zfs commands which are slower, it's not like I can fix that.

In any case, I needed a better solution for managing ZFS boot environments, so I wrote it, and as such, I might as well make it generally available, so here it is.

- Jonathan M Davis