Access boot log

When I boot my NixOS system, I see many lines with a green [OK], and one or two with some orrangy [???] (I cannot read it because things happen too fast; but I am afraid of it; it doesn’t go away either; first I thought it was temporary; nixos unstable, you know… :wink:).

How can I access this log when the system has booted up?

Of course, I tried dmesg, and journalctl, but I cannot find the [OK] lines either, so I am a bit lost.

Thanks!

1 Like

The output is not exactly identical, (no nice checkmarks) but you can view the syslog from the start of the current boot with the --boot option: journalctl -b 0.

1 Like

-x can also be helpful with journalctl

Small side note, I recently learned that just specifying --boot or -b without a numerical argument gives you the current boot. This is nice, because personally I could never remember if the current boot is -1 or 0.

1 Like

Thanks for your input! Espcially the -x flag helped a lot. Now I know that network-local-commands.service is failing. I checked this unit, and it is actually doing nothing (but failing)… Not sure how to deal with this.

The unit file is:

# /etc/systemd/system/network-local-commands.service
[Unit]
After=network-pre.target network-setup.service
Before=network.target
BindsTo=network-setup.service
ConditionCapability=CAP_NET_ADMIN
Description=Extra networking commands.

[Service]
Environment="LOCALE_ARCHIVE=/nix/store/jjqjpirz9v8cky0sh2h3qswx7czc5vp7-glibc-locales-2.34-210/lib/locale/locale-archive"
Environment="PATH=/nix/store/y8nsm2rzlg55d61hblgrq9l1inclhr9a-iproute2-5.17.0/bin:/nix/store/l2xyarvzahpz3fysr9hqbvcsgv5gnrnk-coreutils-9.1/bin:/nix/store/ip1zdc23sqyq15957lbjrxj31m5xh72c-findutils-4.9.0/bin:/nix>
Environment="TZDIR=/nix/store/h8cddb1h4v6ji6jk2nb045rss1qglgpq-tzdata-2022a/share/zoneinfo"

ExecStart=/nix/store/38cnm36971wcxz0wwmw070q0zchh980c-unit-script-network-local-commands-start/bin/network-local-commands-start
RemainAfterExit=true
Type=oneshot

And the network-local-commands-start script is empty:

 + cat /nix/store/38cnm36971wcxz0wwmw070q0zchh980c-unit-script-network-local-commands-start/bin/network-local-commands-start
#!/nix/store/j9rc786ylq8cid4zgcn6idknilkbd4ax-bash-5.1-p16/bin/bash
set -e
# Run any user-specified commands.

This may be considered a bug. The service is created unconditionally here: https://github.com/NixOS/nixpkgs/blob/d8b87359d9f5c3a84e850f0a49ff1a83f5239340/nixos/modules/tasks/network-interfaces.nix#L1439

I think it should be behind a mkIf of some kind, given it only does anything if networking.localCommands is defined.

That said, the error is harmless. It probably fails because systemd sees it exiting too quickly? Maybe give journalctl -xe --unit network-local-commands.service a thorough look and share the actual error - the only other failure I could see is that your nix store is corrupted and that bash is missing.

If it’s just exiting too quickly, a sleep 5 in networking.localCommands, or setting systemd.services.networking-local-commands.config.Restart="never" (or some other systemd setting I don’t know about off the top of my head) would be a sufficient hack to fix the boot messages, I think.

But why is it failing in the first place? Running an empty bash script shouldn’t be considered a failure at all.

1 Like

OK, I found out why it is failing. An After dependency is missing: network-setup.service. I have no idea why this is the case, I suspect this is a problem with Nixpkgs. I found https://github.com/NixOS/nixpkgs/pull/179163, but here, the network-setup.service is in the After, and not the BindsTo clause.

EDIT: This specific problem was fixed by the above mentioned PR.

1 Like