Skip to content

compact: fstrim fails on WSL 3.0 (execvpe does not find /sbin tools) #560

Closed

Description

@zcsizmadia

skrog compact fails at its first step on WSL 3.0.3:

skrog: compact: fstrim in skrog-engine: wsl -d skrog-engine -u root --exec fstrim -v /: exit status 1:
<3>WSL (8 - Relay) ERROR: CreateProcessCommon:875: execvpe(fstrim) failed: No such file or directory

Verified on WSL 3.0.3.0 / Windows 10 19045, against the real engine and against a throwaway distro imported from skrog-rootfs-29.8.2-1-amd64.tar.gz:

  • /sbin/fstrim exists in the rootfs, and env under wsl --exec shows /sbin on PATH.
  • wsl --exec fstrim, wsl --exec sysctl and wsl --exec ip all fail with execvpe(...) failed; wsl --exec ls works. The relay's lookup apparently does not search /sbin.
  • wsl --exec /sbin/fstrim -v / works.

So every skrog compact without --no-trim fails on this WSL. Inferred, not checked: this is a WSL change, since docs/housekeeping.md measured compact against WSL 2.7.8.

internal/compact/compact.go:198 is the only bare-name exec of a /sbin tool in skrog that I found; the others are sh -c or /bin//usr/bin tools.

Fix

Call /sbin/fstrim by its path. The rootfs is ours, so the path is fixed.

Activity

  1. added
    bugSomething isn't working
    P1Fix before v0.3 feature work starts (S0)
    on Oct 25, 2026
  2. zcsizmadia commented on Oct 25, 2026

    @zcsizmadia
    CollaboratorAuthor

    Calling /sbin/fstrim by path fixes the first step: verified live on a throwaway distro, and the unit tests fail without it. It is on the branch fix/560-fstrim-path, not yet pushed.

    It is not enough to make skrog compact work on WSL 3.0.3. The next step fails too:

    skrog: vhdx: CompactVirtualDisk(...\ext4.vhdx): The process cannot access the file because it is being used by another process.
    

    Verified on this machine:

    • With every distro stopped, compaction still failed at 15, 30, 60, 90, 120 and 180 s after the terminate.
    • The utility VM (vmmem) started at 10:43 was still running at 10:52 with no distro running, so it is not idling out after vmIdleTimeout, as the docs measured on WSL 2.7.8 (~66 s).
    • After wsl --shutdown, a new vmmem was up within a second, and compaction failed the same way. I did not identify what starts it; the skrog supervisor (0.8.0) was running throughout.
    • vhdx.Free returns true while the disk is held, so the 90 s wait ends at once and the error comes from CompactVirtualDisk itself. The comment on open(), that this access mode fails at the open, does not hold here.

    wsl --manage <distro> --compact compacts the same disk right after a terminate (#552), because WSL detaches it inside the VM it owns.

  3. zcsizmadia commented on Oct 25, 2026

    @zcsizmadia
    CollaboratorAuthor

    Correction to my previous comment: the utility VM does idle out on WSL 3.0.3. It is skrog compact that keeps restarting it. Verified on this machine:

    • Left alone, the VM (vmmem) exited 60–65 s after the last distro stopped, matching what the docs measured on 2.7.8.
    • wsl -l -v, wsl --list --running and wsl --terminate on a stopped distro do not start it. wsl --manage --compact does.
    • skrog compact started it: vmmem came back the moment it ran. Its stop step calls StopEngine, which runs RemoveEmulation inside the distro before terminating it (Emulation: run foreign-architecture containers via binfmt_misc + qemu-user (opt-in) #462), and that boots a stopped distro.
    • vhdx.Free returned true while the VM held the disk, and vhdx.Compact failed with the sharing violation. Once the VM exited, Free returned true again and Compact succeeded. So Free cannot see this hold, and the wait loop ends at once.

    Together these explain the failure: the stop boots the VM, and the wait does not notice it holding the disk. Inferred, not checked: before #462, a stopped engine was not booted, so the disk was usually already free.

    The fstrim part is fixed in #562. This stays open for the wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1Fix before v0.3 feature work starts (S0)bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions