https://catfox.life/2024/01/05/systemd-through-the-eyes-of-a-musl-distribution-maintainer/ Skip to content [cropped-cat-5-512-85909] The Cat Fox Life Photography, cats, computing, and anecdotes from an Oklahoman fox. Menu * Home * Twitter * Instagram systemd through the eyes of a musl distribution maintainer Welcome back to FOSS Fridays! This week, I'm covering a real pickle. I'm acutely aware of the flames this blog post will inspire, but I feel it is important to write nevertheless. I volunteer my time towards helping to maintain a Linux distribution based on the musl libc, and I am writing an article about systemd. This is my take and my take alone. It is not the opinion of the project - or, as far as I am aware, any of the other volunteers working on it. systemd, as a service manager, is not actually a bad piece of software by itself. The fact it can act as both a service manager and an inetd(8) replacement is really cool. The unit file format is very nice and expressive. Defining mechanism and leaving policy to the administrator is a good design. Of course, nothing exists in a vacuum. I don't like the encouragement to link daemons to libsystemd for better integration - all of the useful integrations can be done with more portable measures. And I really don't like the fact they consider glibc to be "the Linux API" when musl, Bionic, and other libcs exist. I'd like to dive into detail on the good and the bad of systemd, as seen through my eyes as all of: end user, administrator, and developer. Service management: Good Unit files are easy to write by hand, and also easy to generate in an automated fashion. You can write a basic service in a few lines, and grow into using the other features as needs arise - or you can write a very detailed file, dozens of lines long, making it exact and precise. Parallel service starting and socket activation are first-class citizens as well, which is something very important to making boot-up faster and more reliable. The best part about it is the concept that this configuration exactly describes the way the system should appear and exist while it is running. This is similar to how network device standards work - see NETCONF and its stepchild RESTCONF. You define how you want the device to look when it is running, apply the configuration, and eventually the device becomes consistent to that configuration. This is a far cry from OpenRC or SysV init scripts, which focus almost exclusively on spawning processes. It's a powerful paradigm shift, and one I wholeheartedly welcome and endorse. Additionally, the use of cgroups per managed unit means that process tracking is always available, without messy pid files or requiring daemons to never fork. This is another very useful feature that not only helps with overall system control, but also helps debugging and even security auditing. When cgroups are used in this way, you always know which unit spawned any process on a fully-managed system. Lack of competition: Not good There is no reason that another service manager couldn't exist with all of these features. In fact, I hope that there will be competition to systemd that is taken seriously by the community. Having a single package being all things for all use cases leads to significant problems. Changes in systemd will necessarily affect every single user - this may seem obvious, but that means it is more difficult for it to evolve. Evolution of the system may, and in some cases already has, break a wide number of use cases and machines. Additionally, without competition there is no external pressure nudging it towards ideas and concepts that perhaps the maintainers aren't sure about. GCC and Clang learn from each other's successes and failures and use that knowledge to make each other better. There is no package doing that with systemd right now. Innovation is stifled where choice is removed. Misnaming glibc as "the Linux API": Bad I am also unhappy about systemd's lack of musl libc support. That is probably a blessing for me, because it's an easy reason to avoid trying to ship it in Adelie. While I have just spent five paragraphs noting how great systemd is at service management, it is really bad at a lot of other things. This is where most articles go off the deep end, but I want to provide some constructive criticism on some of the issues I've personally faced and felt while using systemd-based machines. The Journal: Very bad journald is my least-favourite feature of systemd, bar none. While I understand the reasons why it was designed the way it was, I do not appreciate that it is the only way to log on a systemd system. Sure, you can ForwardToSyslog and set the journal to be in-memory-only with a small size, and pretend journald doesn't exist. However, that is not only excess processor power and memory usage for negative gain, it's also an additional attack surface. It would be great if there were a "stub" journald that was strictly a forwarder with no other code. I am also unhappy with how the journal tries to "eat" core files. While the Linux default setting of "putting a file named 'core' in $CWD" is absolutely unusable for development and production, the weird mixture of FS and binary journal makes things needlessly complex. The documentation even explicitly calls out that core files may exist without corresponding journal entries, and journal entries may point to core files that no longer exist. Yet they use xattrs to put "some metadata" in the core files. Why not just have a sidecar file (maybe [core file name].info or .json or .whatever) that contains all the information from the journal, and have a single journal entry that points to that file if the administrator is interested in more information about the crash? resolved: A solution looking for a problem resolved might a decent idea on its own, but there are already other packages that can provide a local caching resolver without the many problems of resolved. Moreover, the very idea of a DNS resolver being part of "the system layer" seems ill-advised to me. DNSSEC support is experimental and not handled correctly, and they readily admit that. It's fine to know your limitations, but DNSSEC is something that is incredibly valuable to have on endpoints. I don't really think resolved can be taken seriously without it. It's beyond me how no one has contributed this feature to such a widely-used package. There are odd issues with local domain search. This is made more complicated on home networks where a lot of what it does is overkill. On enterprise networks, it's likely a bad fit anyway, which makes me question why it supports everything it does. Lastly, and relatedly, in my opinion resolved tries to shoehorn too many odd features and protocols without having the basics done first. mDNS is better taken care of by a dedicated package like Avahi. LLMNR support has been deprecated by its creator Microsoft in favour of mDNS for over a year. As LLMNR has always been a security risk, I'm not sure why the support was added in the first place. nspawn: Niche tool for niche uses Any discussion including resolved would be remiss without mentioning the main reason it exists, and that is nspawn. It's an interesting take on being "in between" chroot and a full container like Docker. It has niche uses, and I don't have any real qualms with it, but I've never found it useful in any of my work so I don't have a lot of experience with it. Usually when I am grabbing for chroot I want shared state between host and container, so nspawn wouldn't make sense there. And when I grab for Podman, I want full isolation, which I feel more comfortable handing to a package that has more tooling around it. Ancillary tools: Why in the system layer? networkd is immature, doesn't have a lot of support for advanced use cases, and has no GUI for end users. I don't know why they want to stuff networking into the "system layer" when NetworkManager exists and keeps all the networking goop out of the system layer. timedated seems like a cute way to allow users to change timezones via a PolicyKit action but otherwise seems like something that would be better taken care of by a "real" NTP client like Chrony or NTP. And again, I don't know why it should live in the system layer. systemd-boot only supports EFI, which makes it non-portable and inflexible. You won't find EFI on Power or Z, and I have plenty of ARM boards that don't support mainline U-Boot as well. This really isn't a problem with systemd-boot, as it's totally understandable to only want to deal with a single platform's idiosyncrasies. What is concerning is the fact that distros like Fedora are pivoting away from GRUB in favour of it, which means they are losing even more portability. In conclusion: A summary What I really want to make clear with this article is: * I don't blindly hate systemd, and in fact I really admire many of its qualities as an actual service manager. What I dislike is its attempt to take over what they term the "system layer", when there are no alternatives available. * The problems I have with systemd are tangible and not just hand-wavy "Unix good, sysd bad". * If there was an effort to have systemd separate from all of the other tentacles it has grown, I would genuinely push to have it be available as a service manager in Adelie. I feel that as a service manager - and only as a service manager - it would provide a fantastic user experience that cannot be rivaled by other existing solutions. Thank you for reading. Have a great day, and please remember that behind every keyboard is a real person with real feelings. Share this: * Twitter * Facebook * Like Loading... [7518f]Author awilfoxPosted on January 5, 2024January 6, 2024 Categories FOSS Friday, TechnologyTags computers, Linux, musl, random musing, systemd 11 thoughts on "systemd through the eyes of a musl distribution maintainer" 1. [7930] Lukas says: January 6, 2024 at 3:27 am Laurent Bercot is working on an alternative see: https://skarnet.com/projects/service-manager.html LikeLiked by 1 person Reply 1. [7518] awilfox says: January 6, 2024 at 3:37 am I am very hopeful that s6-rc grows to be that alternative. With enough time and effort, wrappers around some of the most common systemd interfaces (like systemctl, unit files, and sd_notify) could probably even be created so the transition is "seamless". My main concern is that s6-rc is at the end of the day still skaware, and while I know that Adelie (and likely Void and Alpine) wouldn't be averse to it, I don't know if distributions like Debian or Fedora could be convinced. It would be a true game changer if they could. And, by having the components of systemd more modular as I suggest, you could potentially even "mix and match". Maybe some people like the journal, so they could use it with s6-rc if it was separate. LikeLike Reply 1. [b882] Laurent Bercot says: January 6, 2024 at 11:34 am A transition from/to systemd to a different view of the machine will never, and could never, be seamless, because systemd is hopelessly holistic and maximalist. I have written a document for a customer who was thinking about writing an automated unit file conversion tool, and it took me *a week* to fully analyze the unit file format and write this document. And the results aren't exactly hopeful: https://skarnet.org/software/s6/ unit-conversion.html The best effort I've seen to provide systemd as an alternative to another service manager was done by Serge E. Hallyn in Ubuntu 16.04, that supported both systemd and sysvinit with sysv-rc. It was actually really well done - but ultimately it was a lot of hacks to fit a bunch of square pegs into round holes, and not in the fun way. The amount of duct tape and voodoo curses was just too high - and I don't think it would be at all reasonable for Adelie, or any other distro, to do anything resembling it. Unfortunately, I believe systemd has hopelessly fractured the distro world into "systemd-only" and "without systemd". LikeLiked by 1 person 2. [7518] awilfox says: January 6, 2024 at 3:42 pm That document is actually a lot more reassuring than I thought it would be. I hold no illusions, and the word "seamless" was behind scare quotes for a reason. Simple units should be convertible without much issue, but the only way we could ever have true seamless transitions would be if the systemd project wanted to have that as a goal as well. And I highly doubt they will. Having a better service manager that is stable, accessible, and more reliable would definitely be a reason to go through the transition one way, though. LikeLike 2. [7cac] npiazza says: January 6, 2024 at 4:21 am there's also dinit, which is already used by chimera linux. it looks promising https://davmac.org/projects/dinit/ LikeLike Reply 3. [0ab0] Erkin Alp Guney says: January 6, 2024 at 6:53 am Systemd-bsod is also missing from the review. LikeLike Reply 4. [441d] einpoklum says: January 6, 2024 at 10:12 am Have you considered Devuan as the basis for your distribution? It has done quite the good job of removing systemd dependencies, and that should be a decent launch-pad for switching C libraries. If not - perhaps you could pick-and-choose parts of their work to achieve the same for your own distribution. LikeLike Reply 1. [7518] awilfox says: January 6, 2024 at 3:37 pm Our distribution is fine without rebasing on Devuan. We aren't having a problem with removing systemd from the packages we ship, and we're already using musl. This article was primarily about how I wish systemd wasn't as viral, maximalist, and anti-portable as it is. LikeLike Reply 5. [ef61] JSkier says: January 6, 2024 at 12:10 pm This was very well written, thank you. Nice to see others share a similar perspective on systemd. I don't love it, but I don't hate it either, this considering the totality of how huge it's gotten. I basically forced it to be modularized with ArchLinux, limiting what it controls (avoiding resolved, networkd, timesyncd, etc). Wholeheartedly agree that if it was more pluggable out the gate, I'd be an advocate for it as well, instead of walking on eggshells with it. LikeLiked by 1 person Reply 6. [fc4d] Jan says: January 6, 2024 at 2:50 pm There will be no viable alternatives to systemd because because no one really wants to maintain alternatives to udev ( eudev ), logind (elogind ), tmpfiles.d ( opentmpfiles which is dead ) and that is the big problem. LikeLike Reply 1. [7518] awilfox says: January 6, 2024 at 3:44 pm I mean, there *are* alternatives - mdevd, ConsoleKit, and I still don't know why tmpfiles.d needs to exist at all. If there were a *popular* alternative to systemd, that integrated all of those components, there could be a resurgence of support in upstream packages. LikeLike Reply Leave a Reply Cancel reply [ ] [ ] [ ] [ ] [ ] [ ] [ ] D[ ] Post navigation Previous Previous post: The Sinking of the Itanic Search [ ]Search Follow via Email Enter your email address to follow this blog and receive notifications of new posts by email. Type your email... [ ] Follow Join 289 other subscribers The Cat Fox would like you to know... Opinions mine - not those of any employer, past or present. Recent Posts * systemd through the eyes of a musl distribution maintainer * The Sinking of the Itanic * An introduction to features * "Hey, foxy, how are you doing?" * Target. * Home * Twitter * Instagram The Cat Fox Life Create a website or blog at WordPress.com * Comment * Reblog * Subscribe Subscribed + [croppe] The Cat Fox Life Join 49 other subscribers [ ] Sign me up + Already have a WordPress.com account? Log in now. * Privacy * + [croppe] The Cat Fox Life + Customize + Subscribe Subscribed + Sign up + Log in + Copy shortlink + Report this content + View post in Reader + Manage subscriptions + Collapse this bar %d [b]