-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow boot due to dhcpcd (tracking issue) #60900
Comments
Actually, it seems this has been reported by Arch users before: |
This reverts commit 8c85680. This ordering caused issues with certain downstream configurations, see NixOS/nixpkgs#60900
This reverts commit 8c85680. This ordering caused issues with certain downstream configurations, see NixOS/nixpkgs#60900
This reverts commit 8c85680. This ordering caused issues with certain downstream configurations, see NixOS/nixpkgs#60900
Instead of network.target. Fixes NixOS#60900 (delayed boot).
Instead of network.target. Fixes NixOS#60900 (delayed boot).
Reduce boot/startup times See NixOS/nixpkgs#60900
I don't think this has been fixed. Many people seem to describe slow boot times due to dhcpcd in #80871 and I personally still have this issue. |
It should no longer because of network.target, what is your biggest time consumer in |
If I run #64621 (which closed this issue), just changed dhcpcd to be before |
@NilsIrl Ok. But does your multi-user.target depend on it? dhcpcd beeing slow should not be a problem if nothing else depends on it. |
Yes
|
Yes (AFAIK). Before my last comment, I also looked around for the source of this but because all I could find where wantedBy "things", I thought it must be related to something else. But the commit 15d761a reverts, 764c820, mentions decrease in boot time, so I guess it does wait. |
I actually disabled it in the past: https://github.com/Mic92/dotfiles/blob/f07c63d715c949b0831ea50653f6e002cf8c7bcb/nixos/vms/modules/networkd.nix#L4 |
#86484 should fix this (when it is finished). |
I suppose multi-user.target is only marked as done when the online is and the graphical.target requires the multi-user.target. |
@NilsIrl the PR was closed but you can re-open it and do #86484 (comment) |
If
Correct on both counts :) The output of You could try looking at the output of |
Thanks for clarification. |
I'm experiencing an issue like this, but I'm having trouble following the history a little bit. My understanding is that I don't use
So the actual issue is that |
Those services come from: |
Sorry for the noise, I realized the issue was I had a line |
I marked this as stale due to inactivity. → More info |
Another attempt to get rid of the patch is here: #258680, and I expect this one will not be reverted. I think we can close this, even though dhcpcd is itself still slow due to conflict detection (there might be an option to turn that off, but you could also set |
Issue description
At boot, the login window must wait for /run/nologin to be removed (see pam_nologin(8)) .
This happens when systemd launches
systemd-user-sessions.service
, which removes/run/nologin
when it is started, and creates it when it is stopped.Under the default NixOS configuration, there is a significant delay in this process due to systemd waiting for
dhcpcd.service
to fork. The root cause is a gross hack in upstream systemd, which seeks to provide clean termination of inbound SSH sessions by orderingsystemd-user-sessions.service
afternetwork.target
:systemd/systemd@8c85680 fixes systemd/systemd#2390
This was done so that at shutdown, systemd will kill the SSH sessions (by stopping
systemd-user-sessions.service
) before bringing down the network.The inevitable problem is that now, local logins must wait at boot for
network.target
, which is silly. It wouldn't matter much, except that NixOS hasdhcpcd.service
configured to blocknetwork.target
instead of justnetwork-online.target
: #44524It appears that this issue has gone largely unnoticed because other distros either don't use dhcpcd, use it in background mode, ignore the /run/nologin mechanism (which appears to be something of a relic - I can't find much discussion about it), or have
dhcpcd.service
blocking onlynetwork-online.target
, in which case login will be blocked only by a few service initializations that don't take very long.Workarounds:
Ordered best to worst, in my opinion. Any of these should be OK for home use.
systemd.services.systemd-user-sessions.enable = false;
(after rebuild dorm /run/nologin
)networking.dhcpcd.enable = false;
systemd.network.enable = true;
systemd.network.networks = { internet0 = { matchConfig = { Name = "<device>"; }; networkConfig = { DHCP = "ipv4"; }; }; };
(where<device>
iseth0
or whatever)dhcpcd
time out fast, and unplug seatbelts:networking.dhcpcd.extraConfig = "timeout 1\nnoarp\nnodelay";
Seems to work when multiple interfaces are available. Man page says
If dhcpcd is working on a single interface then dhcpcd will exit when a timeout occurs.
I don't know what will happen in that case.dhcpcd
fork to background immediatelysystemd.services.dhcpcd.serviceConfig.ExecStart = pkgs.stdenv.lib.mkForce "@${pkgs.dhcpcd}/sbin/dhcpcd dhcpcd -b --quiet --config /nix/store/<...>-dhcpcd.conf";
The nixos module doesn't export the generated conf path, so it has to be found manually (
ps ax | grep dhcp
) and kept updated. Or replace it with a separate one.network.target
inactive, presumably due systemd barfing on a cyclic dependency.Suggested solution for NixOS:
See also #50930, #58526
Steps to reproduce
Boot a NixOS machine with networking and dhcp(cd) enabled, but no network connection available.
Expected behavior
The machine should boot and present a login window just as quickly as with the network available.
Actual behavior
User is presented with a black screen for up to 30 seconds before login window appears.
The text was updated successfully, but these errors were encountered: