0

I am working on an embedded system. I wrote an environment generator in bash and it seems to work just fine. However I get some errors in the journal:

May 28 02:03:14 imx6ull14x14evk systemd[121]: /etc/systemd/system-environment-generators/overlayroot-ubifs.sh failed with exit status 32.       
May 28 02:03:14 imx6ull14x14evk systemd[121]: Invalid variable assignment "overlay /mnt/user/overlay overlay rw,noatime,lowerdir=...", ignoring.
May 28 02:03:14 imx6ull14x14evk systemd[121]: Invalid variable assignment "overlay / overlay rw,relatime,lowerdir=...", ignoring.      
May 28 02:03:14 imx6ull14x14evk systemd[121]: Invalid variable assignment "devtmpfs /orig/dev devtmpfs rw,relatime,size=...", ignoring.
May 28 02:03:14 imx6ull14x14evk systemd[121]: Invalid variable assignment "tmpfs /orig/run tmpfs rw,nosuid,nodev,mode=...", ignoring.         

I notice that both stdout and stderr seem to be suppressed. logger doesn't work, maybe because systemd-journald.service has not yet started? Or maybe because logger is from busybox and it is not compatible? I noticed that the poky/yocto defaults are writing to rsyslog from logger, not the systemd journal.

If I turn on systemd.log_level=debug as a kernel boot argument, my errors disappear (disconcerting). My errors are not hurting anything as far as I can tell, but I would like to clean it up. Setting systemd.log_level=debug causes other generators to be noted in the journal:

May 28 02:14:43 imx6ull14x14evk kernel: UBIFS (ubi0:1): FS size: 424099840 bytes (404 MiB, 1670 LEBs), journal size 21331968 bytes (20 MiB, 84 LEBs)     mber 2 using ci_hdrck_data_crc mtdparts=gpmi-nand:4m(nandboot),-(nandubi)
              3 imx6ull14x14evk kernel: UBIFS (ubi0:1): reserved for root: 4952683 bytes (4836 KiB)                               
May 28 02:14:43 imx6ull14x14evk kernel: UBIFS (ubi0:1): media format: w5/r0 (latest is w5/r0), UUID 29F89BD4-13AA-4118-B7B7-2B15D8F97EDB, small LPT model
May 28 02:14:43 imx6ull14x14evk systemd-rc-local-generator[196]: /etc/rc.local does not exist, skipping.                                          
May 28 02:14:43 imx6ull14x14evk systemd-hibernate-resume-generator[195]: Not running in an initrd, quitting.                                                                                      
May 28 02:14:43 imx6ull14x14evk systemd-getty-generator[193]: Automatically adding serial getty for /dev/ttymxc0.                                       
May 28 02:14:43 imx6ull14x14evk systemd-gpt-auto-generator[194]: Neither root nor /usr file system are on a (single) block device.                         vice= 3.18
le entries: 513 imx6ull14x14evk systemd-fstab-generator[192]: Parsing /etc/fstab...                                               

So how does systemd-rc-local-generator create the message

/etc/rc.local does not exist, skipping

in the journal? Do I have to write my environment generator in C to be able to print messages (I am willing if required)? Can I get messages without setting systemd.log_level=debug?

1 Answer 1

1

You can't log to the journal, because the journal isn't running at this point yet. Indeed the whole thing about systemd generators being able to produce new unit files is that they run before literally any systemd unit has been started.

You can, however, log to the kernel log buffer (i.e. the dmesg buffer), and your messages will be imported by journald together with all other kernel messages.

To do this, write your message to /dev/kmsg, optionally with the kernel-style severity prefix:

echo "foobar-generator[$$]: Something's going on" > /dev/kmsg
echo "<4>foobar-generator[$$]: Warning, an error is about to occur" > /dev/kmsg
echo "<3>foobar-generator[$$]: An error just occured" > /dev/kmsg

Severity can be specified using "<n>" prefixes, also the same as syslog. (For example, 3 is LOG_ERR, 4 is LOG_WARN, 7 is LOG_DEBUG.) And yes, you need to add the syslog-style "process[pid]:" label yourself.

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.