Mask systemd-networkd-wait-online.service during boot (#13611)

This commit is contained in:
Blue 2025-11-20 17:23:12 +00:00 committed by GitHub
parent dbf49f1ae9
commit f75997128d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View File

@ -329,6 +329,10 @@ int GenerateSystemdUnits(int Argc, char** Argv)
File.reset();
}
// Mask systemd-networkd-wait-online.service since WSL always ensures that networking is configured during boot.
// That unit can cause systemd boot timeouts since WSL's network interface is unmanaged by systemd.
THROW_LAST_ERROR_IF(symlink("/dev/null", std::format("{}/systemd-networkd-wait-online.service", installPath).c_str()) < 0);
// Only create the wslg unit if both enabled in wsl.conf, and if the wslg folder actually exists.
if (enableGuiApps && access("/mnt/wslg/runtime-dir", F_OK) == 0)
{

View File

@ -211,6 +211,12 @@ class UnitTests
auto revert = EnableSystemd();
VERIFY_IS_TRUE(IsSystemdRunning(L"--system"));
// Validate that systemd-networkd-wait-online.service is masked.
auto [out, _] =
LxsstuLaunchWslAndCaptureOutput(L"systemctl status systemd-networkd-wait-online.service | grep -iF Loaded:");
VERIFY_ARE_EQUAL(out, L" Loaded: masked (Reason: Unit systemd-networkd-wait-online.service is masked.)\n");
}
TEST_METHOD(SystemdUser)