0 Items

I’ve been building embedded Linux systems for more than 10 years. This means I’ve worked a lot with sysV style init. It is robust and time tested, but it has its limitations. There are now multiple projects working to supplant sysinit’s dominance, such as Upstart and systemd.

I work quite a bit with Fedora, building both nfsroot filesystems for diskless workstations, and embedded firmware based on Fedora repositories. Fedora is an odd choice for this kind of work; most people would go with Debian or Ubuntu.

Fedora migrated to systemd back in release 15. Since systemd was new, I decided to hold back and not upgrade all my toolchains to Fedora 15. Now we are on 17, and things look rather stable. So I took the plunge on making an nfsroot system using Fedora 17. The end result is similar to LTSP5/Meukow – only all the packages are awesomely new thanks to Fedora being on the cutting edge.

Documentation on systemd is sparse, so I had some trouble figuring out how to trim systemd down. With sysinit things are easier. You just cut through rc.sysinit till it looks nice and trim. You also use chkconfig to turn off irrelevant services. And of course disable selinux. The Fedora team has put up some useful documentation on tweaking and using systemd. They also have a sysVinit to systemd cheatsheet, and a debugging guide. These pages were a great help.

When I first tried booting my nfsroot filesystem, it wouldn’t boot. By adding

systemd.confirm_spawn=true

to the kernel commandline, I was able to control each command in systemd, and figure out which once was crashing.

A nice ability of systemd is to run chkconfig style commands on a chroot filesystem, without chrooting into it. This is similar to yum’s –installroot functionality, which is what I used to build the filesystem in the first place. So, to disable cron on the new system you just build, you’d give

systemctl --system --root=$TARGET disable crond.service

Where $TARGET is the path to your chroot.

There are a number of services that systemd launches, which cannot be disabled using the command above. Hyperlinks to these services/commands also do not exist in /etc/systemd. The only way I found was to delete symlinks to these commands from /lib/systemd/system. Some of the commands that I found to be of no use in an embedded/desktop system are:

/lib/systemd/system/sysinit.target.wants/*binfmt*
/lib/systemd/system/sysinit.target.wants/cryptsetup.target
/lib/systemd/system/sysinit.target.wants/dev-hugepages.target
/lib/systemd/system/basic.target.wants/fedora-configure.service
/lib/systemd/system/local-fs.target.wants/fedora-import-state.service
/lib/systemd/system/local-fs.target.wants/fedora-readonly.service
/lib/systemd/system/local-fs.target.wants/fedora-storage-init*.service