#1126304 apt upgrade and 'Failed to take /etc/passwd lock: Invalid argument'

Package:
systemd
Source:
systemd
Description:
system and service manager
Submitter:
Date:
2026-02-23 18:04:11 UTC
Severity:
normal
Tags:
#1126304#5
Date:
2026-01-23 23:17:01 UTC
From:
To:
I'm working with Debian 13 (Trixie) on a Windows machine.  Debian was
installed via Windows Subsystem for Linux (WSL).  When I run `apt-get
upgrade` I receive the error shown below.

The machine uses WSL v1.  I cannot convert to WSL v2 due to company
policy.  WSL v2 is considered too risky due to lack of security
controls for some operations.

There's a good Q&A on Super User about the problem:
<https://superuser.com/q/1803992>.  One person identified the problem:
<https://superuser.com/a/1805742>.  Another person's answer seems very
relevant: <https://superuser.com/a/1912487>.  In the answer, the
poster says:

    The simplest fix is to just disable error-checking on calls to
    systemd-sysusers so it doesn't prevent the post-install scripts from
    completing. This can be done with the following command...

Debian should consider ignoring failures in calls
`fcntl(F_OFD_SETLKW)`.  Or, go back to the old `fcntl(F_SETLKW)`.

Or another workaround?
----------

$ sudo apt-get upgrade
...
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
5 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Setting up systemd (257.9-1~deb13u1) ...
 Failed to take /etc/passwd lock: Invalid argument

dpkg: error processing package systemd (--configure):
 installed systemd package post-installation script subprocess
returned error exit status 1
dpkg: dependency problems prevent configuration of systemd-sysv:
 systemd-sysv depends on systemd (= 257.9-1~deb13u1); however:
  Package systemd is not configured yet.
 systemd-sysv depends on systemd; however:
  Package systemd is not configured yet.

dpkg: error processing package systemd-sysv (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 systemd
 systemd-sysv

#1126304#10
Date:
2026-01-24 00:40:30 UTC
From:
To:
And it looks like Poettering won't fix:
<https://github.com/systemd/systemd/issues/29512>.

#1126304#15
Date:
2026-01-24 04:58:57 UTC
From:
To:
It is also worth noticing that the same issue is reported to Ubuntu as
<URL: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/2069555 >
and Microsoft as <URL: https://github.com/microsoft/WSL/issues/1927 >.

#1126304#22
Date:
2026-01-24 05:09:04 UTC
From:
To:
A workaround could be to implementing a shared library to load using
LD_PRELOAD, which could provide a fcntl() wrapper masking the lack of
F_OFD_SETLKW in WSL 1 by implementing the same broken locking mechanism
as F_SETLK?  Then one could use `LD_PRELOAD=brokenwsllocking apt
upgrade` or similar to upgrade systemd when using WSL 1.

#1126304#25
Date:
2026-01-24 05:09:04 UTC
From:
To:
A workaround could be to implementing a shared library to load using
LD_PRELOAD, which could provide a fcntl() wrapper masking the lack of
F_OFD_SETLKW in WSL 1 by implementing the same broken locking mechanism
as F_SETLK?  Then one could use `LD_PRELOAD=brokenwsllocking apt
upgrade` or similar to upgrade systemd when using WSL 1.

#1126304#30
Date:
2026-01-26 14:55:00 UTC
From:
To:
Thanks for your input Petter.

I was thinking about the issue over the weekend.  Here's a few thoughts.

First, Microsoft has an article at <
https://learn.microsoft.com/en-us/windows/wsl/systemd#how-to-enable-systemd>.
But it is not very useful since it is trying to enable Systemd.  (Thanks
Alfie!)

Second, we can convert from Systemd to SysV.  That may be the best path for
WSL since folks like me are simply trying to get a command prompt
(terminal) with classic Unix & Linux commands.  We are not trying to run a
full blown vm with multi-user capabilities.

Third, would running in single-user mode sidestep the problem or make
locking less of an issue?  I think we can enable single-user mode in
Systemd with the command `sudo systemctl rescue`.

Any thoughts?

#1126304#35
Date:
2026-01-26 15:55:25 UTC
From:
To:
Thanks again Petter.

I found a work-around.  Someone suggested it at <
https://superuser.com/a/1922859>.  However, due to corporate policy (no
network for WSL-2), I had to modify it a bit:

1. Open Debian VM.  It is WSL-1
2. Run `sudo apt-get update`.  WSL-1 is allowed on the network
3. Close Debian VM
4. In Windoze cmd prompt run `wsl --set-version Debian 2`.  Convert to WSL-2
5. Open Debian VM.  It is WSL-2
6. Run `sudo apt-get upgrade`.  WSL-2 file locks work
7. Close Debian VM
8. In Windoze cmd prompt run `wsl --set-version Debian 1`.  Convert to WSL-1
9. Open Debian VM.  It is WSL-1 again