Skip to content

Commit f759971

Browse files
authored
Mask systemd-networkd-wait-online.service during boot (#13611)
1 parent dbf49f1 commit f759971

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/linux/init/init.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ int GenerateSystemdUnits(int Argc, char** Argv)
329329
File.reset();
330330
}
331331

332+
// Mask systemd-networkd-wait-online.service since WSL always ensures that networking is configured during boot.
333+
// That unit can cause systemd boot timeouts since WSL's network interface is unmanaged by systemd.
334+
THROW_LAST_ERROR_IF(symlink("/dev/null", std::format("{}/systemd-networkd-wait-online.service", installPath).c_str()) < 0);
335+
332336
// Only create the wslg unit if both enabled in wsl.conf, and if the wslg folder actually exists.
333337
if (enableGuiApps && access("/mnt/wslg/runtime-dir", F_OK) == 0)
334338
{

test/windows/UnitTests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,12 @@ class UnitTests
211211

212212
auto revert = EnableSystemd();
213213
VERIFY_IS_TRUE(IsSystemdRunning(L"--system"));
214+
215+
// Validate that systemd-networkd-wait-online.service is masked.
216+
auto [out, _] =
217+
LxsstuLaunchWslAndCaptureOutput(L"systemctl status systemd-networkd-wait-online.service | grep -iF Loaded:");
218+
219+
VERIFY_ARE_EQUAL(out, L" Loaded: masked (Reason: Unit systemd-networkd-wait-online.service is masked.)\n");
214220
}
215221

216222
TEST_METHOD(SystemdUser)

0 commit comments

Comments
 (0)