microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
16.96k stars 798 forks source link

The contents of `/tmp` are cleared few seconds after start up #11739

Open LeonardoMor opened 2 weeks ago

LeonardoMor commented 2 weeks ago

Windows Version

Microsoft Windows [Version 10.0.22621.3737]

WSL Version

WSL version: 2.2.4.0 Kernel version: 5.15.153.1-2 WSLg version: 1.0.61 MSRDC version: 1.2.5326 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26091.1-240325-1447.ge-release Windows version: 10.0.22621.3737

Are you using WSL 1 or WSL 2?

Kernel Version

Linux version 5.15.153.1-microsoft-standard-WSL2 (root@941d701f84f1) (gcc (GCC) 11.2.0, GNU ld (GNU Binutils) 2.37) #1 SMP Fri Mar 29 23:14:13 UTC 2024

Distro Version

NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling VERSION_ID=20240101.0.204074 ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://bugs.archlinux.org/" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo

Other Software

No response

Repro Steps

  1. On startup touch /tmp/file
  2. Wait a few seconds. The file will be gone.

Expected Behavior

Feature parity to bare-metal Linux. That is, files created under /tmp on startup should not be removed after such a short period.

Actual Behavior

The file is removed.

I learned this because I use blesh. See this discussion

Diagnostic Logs

WslLogs-2024-07-02_20-47-17.zip

github-actions[bot] commented 2 weeks ago

Logs are required for review from WSL team

If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'. Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

How to collect WSL logs Download and execute [collect-wsl-logs.ps1](https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1) in an **administrative powershell prompt**: ``` Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1 Set-ExecutionPolicy Bypass -Scope Process -Force .\collect-wsl-logs.ps1 ``` The scipt will output the path of the log file once done. Once completed please upload the output files to this Github issue. [Click here for more info on logging](https://github.com/microsoft/WSL/blob/master/CONTRIBUTING.md#8-collect-wsl-logs-recommended-method) If you choose to email these logs instead of attaching to the bug, please send them to wsl-gh-logs@microsoft.com with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

LeonardoMor commented 2 weeks ago

Related #8441

github-actions[bot] commented 2 weeks ago
Diagnostic information ``` Issue was edited and new log file was found: https://github.com/user-attachments/files/16076419/WslLogs-2024-07-02_20-47-17.zip Detected appx version: 2.2.4.0 ```
akinomyoga commented 2 weeks ago

This is the same issue as #8441, but #8441 is closed for some inactivity. It's not solved. The problem is not specific to ble.sh, but there are also problems with other frameworks.

Clearing /tmp on startup of WSL is fine, but it should not happen after programs start to use /tmp. Clearing /tmp should be finished in the booting-up process of the system before any programs that may use /tmp start. The current behavior would affect all the programs that use /tmp in their initialization stage.

OneBlue commented 1 week ago

@LeonardoMor Do you have systemd enabled in your distro ?

This is most likely caused by the systemd-tmpfiles-clean.service unit. Can you try running:

systemctl mask systemd-tmpfiles-clean.service and see if that solves the issue ?

Also if doesn't, can you share the output of cat /proc/self/mountinfo before and after the file is deleted ?

LeonardoMor commented 1 week ago

systemd is indeed enabled:

❯ ps --no-headers -o comm 1
systemd

cat /proc/self/mountinfo before and after:

asciicast

❯ printf '%s: %s: $ cat /proc/self/mountinfo\n%s\n' Before "$(date -Iseconds)" "$(cat /proc/self/mountinfo)"                                                                                                                                
Before: 2024-07-09T19:25:26-06:00: $ cat /proc/self/mountinfo                                                                                                                                                                               
74 82 0:26 / /mnt/wsl rw,relatime shared:1 - tmpfs none rw                                                                                                                                                                                  
75 82 0:28 / /usr/lib/wsl/drivers ro,nosuid,nodev,noatime - 9p drivers ro,dirsync,aname=drivers;fmask=222;dmask=222,mmap,access=client,msize=65536,trans=fd,rfd=7,wfd=7                                                                     
80 82 0:36 / /usr/lib/modules rw,relatime - tmpfs none rw                                                                                                                                                                                   
81 80 0:33 / /usr/lib/modules/5.15.153.1-microsoft-standard-WSL2 rw,nosuid,nodev,noatime - overlay none rw,lowerdir=/modules,upperdir=/modules_overlay/rw/upper,workdir=/modules_overlay/rw/work                                            
82 66 8:32 / / rw,relatime - ext4 /dev/sdc rw,discard,errors=remount-ro,data=ordered                                                                                                                                                        
83 82 0:38 / /mnt/wslg rw,relatime shared:2 - tmpfs none rw                                                                                                                                                                                 
84 83 8:32 / /mnt/wslg/distro ro,relatime shared:3 - ext4 /dev/sdc rw,discard,errors=remount-ro,data=ordered                                                                                                                                
100 82 0:46 / /usr/lib/wsl/lib rw,nosuid,nodev,noatime - overlay none rw,lowerdir=/gpu_lib_packaged:/gpu_lib_inbox,upperdir=/gpu_lib/rw/upper,workdir=/gpu_lib/rw/work                                                                      
101 82 0:2 /init /init ro - rootfs rootfs rw,size=8107332k,nr_inodes=2026833                                                                                                                                                                
113 82 0:5 / /dev rw,nosuid,relatime shared:15 - devtmpfs none rw,size=8107332k,nr_inodes=2026833,mode=755                                                                                                                                  
117 82 0:20 / /sys rw,nosuid,nodev,noexec,noatime shared:19 - sysfs sysfs rw                                                                                                                                                                
118 82 0:63 / /proc rw,nosuid,nodev,noexec,noatime shared:20 - proc proc rw                                                                                                                                                                 
119 113 0:64 / /dev/pts rw,nosuid,noexec,noatime shared:21 - devpts devpts rw,gid=5,mode=620,ptmxmode=000                                                                                                                                   
120 82 0:65 / /run rw,nosuid,nodev shared:22 - tmpfs none rw,mode=755                                                                                                                                                                       
121 120 0:66 / /run/lock rw,nosuid,nodev,noexec,noatime shared:23 - tmpfs none rw                                                                                                                                                           
122 120 0:67 / /run/shm rw,nosuid,nodev,noatime shared:24 - tmpfs none rw                                                                                                                                                                   
123 113 0:67 / /dev/shm rw,nosuid,nodev,noatime shared:24 - tmpfs none rw                                                                                                                                                                   
124 120 0:68 / /run/user rw,nosuid,nodev,noexec,noatime shared:25 - tmpfs none rw,mode=755                                                                                                                                                  
125 118 0:27 / /proc/sys/fs/binfmt_misc rw,relatime shared:26 - binfmt_misc binfmt_misc rw                                                                                                                                                  
126 117 0:69 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:27 - tmpfs tmpfs ro,size=4096k,nr_inodes=1024,mode=755                                                                                                                          
127 126 0:21 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:28 - cgroup2 cgroup2 rw,nsdelegate                                                                                                                             
130 126 0:60 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:31 - cgroup cgroup rw,cpuset                                                                                                                                    
131 126 0:61 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime shared:32 - cgroup cgroup rw,cpu                                                                                                                                          
132 126 0:62 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime shared:33 - cgroup cgroup rw,cpuacct                                                                                                                                  
133 126 0:70 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:34 - cgroup cgroup rw,blkio                                                                                                                                      
134 126 0:71 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:35 - cgroup cgroup rw,memory                                                                                                                                    
138 126 0:72 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:39 - cgroup cgroup rw,devices                                                                                                                                  
140 126 0:73 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:41 - cgroup cgroup rw,freezer                                                                                                                                  
142 126 0:74 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime shared:43 - cgroup cgroup rw,net_cls                                                                                                                                  
143 126 0:75 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:44 - cgroup cgroup rw,perf_event                                                                                                                            
145 126 0:76 / /sys/fs/cgroup/net_prio rw,nosuid,nodev,noexec,relatime shared:46 - cgroup cgroup rw,net_prio                                                                                                                                
146 126 0:77 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:47 - cgroup cgroup rw,hugetlb                                                                                                                                  
148 126 0:78 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:49 - cgroup cgroup rw,pids                                                                                                                                        
150 126 0:79 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:51 - cgroup cgroup rw,rdma                                                                                                                                        
152 126 0:80 / /sys/fs/cgroup/misc rw,nosuid,nodev,noexec,relatime shared:53 - cgroup cgroup rw,misc                                                                                                                                        
156 83 0:40 /etc/versions.txt /mnt/wslg/versions.txt rw,relatime shared:54 - overlay none rw,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/system/rw/work                                                                          
158 83 0:40 /usr/share/doc /mnt/wslg/doc rw,relatime shared:55 - overlay none rw,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/system/rw/work                                                                                      
160 82 0:38 /.X11-unix /tmp/.X11-unix ro,relatime shared:2 - tmpfs none rw                                                                                                                                                                  
161 82 0:83 / /mnt/c rw,noatime - 9p C:\134 rw,dirsync,aname=drvfs;path=C:\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=5,wfd=5                                                                         
162 124 0:38 /run/user /run/user rw,relatime shared:2 - tmpfs none rw                                                                                                                                                                       
163 126 0:84 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:56 - cgroup cgroup rw,xattr,name=systemd

❯ touch /tmp/test.tmp; while true; do printf '%s: $ ls -lat /tmp | head\n%s\n\n' "$(date -Iseconds)" "$(ls -lat /tmp | head)"; sleep 2; done                                                                                                
2024-07-09T19:25:36-06:00: $ ls -lat /tmp | head                                                                                                                                                                                            
total 3448                                                                                                                                                                                                                                  
-rw-r--r--  1 leo  leo       0 Jul  9 19:25 test.tmp                                                                                                                                                                                        
drwxrwxrwt 47 root root   4096 Jul  9 19:25 .                                                                                                                                                                                               
drwx------  2 leo  leo    4096 Jul  9 19:25 ssh-XXXXXXnIkT5N                                                                                                                                                                                
drwxr-xr-x 18 root root   4096 Jul  9 19:25 ..                                                                                                                                                                                              
drwxrwxrwx  2 root root     60 Jul  9 19:25 .X11-unix                                                                                                                                                                                       
drwx------  2 leo  leo    4096 Jul  9 19:24 ssh-XXXXXXmAvC2x                                                                                                                                                                                
drwx------  2 leo  leo    4096 Jul  9 19:23 tmux-1000                                                                                                                                                                                       
drwx------  2 leo  leo    4096 Jul  9 19:23 ssh-XXXXXXrBaswW                                                                                                                                                                                
drwx------  2 leo  leo    4096 Jul  9 19:22 ssh-XXXXXXFg5aZ

...

2024-07-09T19:25:42-06:00: $ ls -lat /tmp | head                                                                                                                                                                                            
total 3448                                                                                                                                                                                                                                  
-rw-r--r--  1 leo  leo       0 Jul  9 19:25 test.tmp                                                                                                                                                                                        
drwxrwxrwt 47 root root   4096 Jul  9 19:25 .                                                                                                                                                                                               
drwx------  2 leo  leo    4096 Jul  9 19:25 ssh-XXXXXXnIkT5N                                                                                                                                                                                
drwxr-xr-x 18 root root   4096 Jul  9 19:25 ..                                                                                                                                                                                              
drwxrwxrwx  2 root root     60 Jul  9 19:25 .X11-unix                                                                                                                                                                                       
drwx------  2 leo  leo    4096 Jul  9 19:24 ssh-XXXXXXmAvC2x                                                                                                                                                                                
drwx------  2 leo  leo    4096 Jul  9 19:23 tmux-1000                                                                                                                                                                                       
drwx------  2 leo  leo    4096 Jul  9 19:23 ssh-XXXXXXrBaswW                                                                                                                                                                                
drwx------  2 leo  leo    4096 Jul  9 19:22 ssh-XXXXXXFg5aZw                                                                                                                                                                                

2024-07-09T19:25:44-06:00: $ ls -lat /tmp | head                                                                                                                                                                                            
total 4                                                                                                                                                                                                                                     
drwxrwxrwt  8 root root  160 Jul  9 19:25 .                                                                                                                                                                                                 
drwx------  3 root root   60 Jul  9 19:25 systemd-private-8cae43c7d3124da9be80e2796f378d53-systemd-logind.service-6nGJTr                                                                                                                    
drwx------  3 root root   60 Jul  9 19:25 systemd-private-8cae43c7d3124da9be80e2796f378d53-dbus-broker.service-7Y68yN                                                                                                                       
drwxrwxrwt  2 root root   40 Jul  9 19:25 .font-unix                                                                                                                                                                                        
drwxrwxrwt  2 root root   40 Jul  9 19:25 .ICE-unix                                                                                                                                                                                         
drwxrwxrwt  2 root root   40 Jul  9 19:25 .X11-unix                                                                                                                                                                                         
drwxrwxrwt  2 root root   40 Jul  9 19:25 .XIM-unix                                                                                                                                                                                         
drwxr-xr-x 18 root root 4096 Jul  9 19:25 ..  
...

❯ printf '%s: %s: $ cat /proc/self/mountinfo\n%s\n' After "$(date -Iseconds)" "$(cat /proc/self/mountinfo)"
After: 2024-07-09T19:25:59-06:00: $ cat /proc/self/mountinfo
74 82 0:26 / /mnt/wsl rw,relatime shared:1 - tmpfs none rw
75 82 0:28 / /usr/lib/wsl/drivers ro,nosuid,nodev,noatime - 9p drivers ro,dirsync,aname=drivers;fmask=222;dmask=222,mmap,access=client,msize=65536,trans=fd,rfd=7,wfd=7
80 82 0:36 / /usr/lib/modules rw,relatime - tmpfs none rw
81 80 0:33 / /usr/lib/modules/5.15.153.1-microsoft-standard-WSL2 rw,nosuid,nodev,noatime - overlay none rw,lowerdir=/modules,upperdir=/modules_overlay/rw/upper,workdir=/modules_overlay/rw/work
82 66 8:32 / / rw,relatime - ext4 /dev/sdc rw,discard,errors=remount-ro,data=ordered
83 82 0:38 / /mnt/wslg rw,relatime shared:2 - tmpfs none rw
84 83 8:32 / /mnt/wslg/distro ro,relatime shared:3 - ext4 /dev/sdc rw,discard,errors=remount-ro,data=ordered
100 82 0:46 / /usr/lib/wsl/lib rw,nosuid,nodev,noatime - overlay none rw,lowerdir=/gpu_lib_packaged:/gpu_lib_inbox,upperdir=/gpu_lib/rw/upper,workdir=/gpu_lib/rw/work
101 82 0:2 /init /init ro - rootfs rootfs rw,size=8107332k,nr_inodes=2026833
113 82 0:5 / /dev rw,nosuid,relatime shared:15 - devtmpfs none rw,size=8107332k,nr_inodes=2026833,mode=755
117 82 0:20 / /sys rw,nosuid,nodev,noexec,noatime shared:19 - sysfs sysfs rw
118 82 0:63 / /proc rw,nosuid,nodev,noexec,noatime shared:20 - proc proc rw
119 113 0:64 / /dev/pts rw,nosuid,noexec,noatime shared:21 - devpts devpts rw,gid=5,mode=620,ptmxmode=000
120 82 0:65 / /run rw,nosuid,nodev shared:22 - tmpfs none rw,mode=755
121 120 0:66 / /run/lock rw,nosuid,nodev,noexec,noatime shared:23 - tmpfs none rw
122 120 0:67 / /run/shm rw,nosuid,nodev,noatime shared:24 - tmpfs none rw
123 113 0:67 / /dev/shm rw,nosuid,nodev,noatime shared:24 - tmpfs none rw
124 120 0:68 / /run/user rw,nosuid,nodev,noexec,noatime shared:25 - tmpfs none rw,mode=755
125 118 0:27 / /proc/sys/fs/binfmt_misc rw,relatime shared:26 - binfmt_misc binfmt_misc rw
126 117 0:69 / /sys/fs/cgroup ro,nosuid,nodev,noexec shared:27 - tmpfs tmpfs ro,size=4096k,nr_inodes=1024,mode=755
127 126 0:21 / /sys/fs/cgroup/unified rw,nosuid,nodev,noexec,relatime shared:28 - cgroup2 cgroup2 rw,nsdelegate
130 126 0:60 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:31 - cgroup cgroup rw,cpuset
131 126 0:61 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime shared:32 - cgroup cgroup rw,cpu
132 126 0:62 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime shared:33 - cgroup cgroup rw,cpuacct
133 126 0:70 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:34 - cgroup cgroup rw,blkio
134 126 0:71 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:35 - cgroup cgroup rw,memory
138 126 0:72 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:39 - cgroup cgroup rw,devices
140 126 0:73 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:41 - cgroup cgroup rw,freezer
142 126 0:74 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime shared:43 - cgroup cgroup rw,net_cls
143 126 0:75 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:44 - cgroup cgroup rw,perf_event
145 126 0:76 / /sys/fs/cgroup/net_prio rw,nosuid,nodev,noexec,relatime shared:46 - cgroup cgroup rw,net_prio
146 126 0:77 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:47 - cgroup cgroup rw,hugetlb
148 126 0:78 / /sys/fs/cgroup/pids rw,nosuid,nodev,noexec,relatime shared:49 - cgroup cgroup rw,pids
150 126 0:79 / /sys/fs/cgroup/rdma rw,nosuid,nodev,noexec,relatime shared:51 - cgroup cgroup rw,rdma
152 126 0:80 / /sys/fs/cgroup/misc rw,nosuid,nodev,noexec,relatime shared:53 - cgroup cgroup rw,misc
156 83 0:40 /etc/versions.txt /mnt/wslg/versions.txt rw,relatime shared:54 - overlay none rw,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/system/rw/work
158 83 0:40 /usr/share/doc /mnt/wslg/doc rw,relatime shared:55 - overlay none rw,lowerdir=/systemvhd,upperdir=/system/rw/upper,workdir=/system/rw/work
160 82 0:38 /.X11-unix /tmp/.X11-unix ro,relatime shared:2 - tmpfs none rw
161 82 0:83 / /mnt/c rw,noatime - 9p C:\134 rw,dirsync,aname=drvfs;path=C:\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=5,wfd=5
162 124 0:38 /run/user /run/user rw,relatime shared:2 - tmpfs none rw
163 126 0:84 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:56 - cgroup cgroup rw,xattr,name=systemd
164 113 0:85 / /dev/hugepages rw,nosuid,nodev,relatime shared:57 - hugetlbfs hugetlbfs rw,pagesize=2M
165 117 0:6 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime shared:58 - debugfs debugfs rw
166 113 0:37 / /dev/mqueue rw,nosuid,nodev,noexec,relatime shared:59 - mqueue mqueue rw
167 117 0:11 / /sys/kernel/tracing rw,nosuid,nodev,noexec,relatime shared:60 - tracefs tracefs rw
168 82 0:86 / /tmp rw,nosuid,nodev - tmpfs tmpfs rw,nr_inodes=1048576
231 120 0:87 / /run/credentials/systemd-journald.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:61 - ramfs none rw,mode=700
233 120 0:88 / /run/credentials/systemd-tmpfiles-setup-dev-early.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:62 - ramfs none rw,mode=700
235 120 0:89 / /run/credentials/systemd-udev-load-credentials.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:63 - ramfs none rw,mode=700
169 117 0:90 / /sys/fs/fuse/connections rw,nosuid,nodev,noexec,relatime shared:64 - fusectl fusectl rw
239 120 0:91 / /run/credentials/systemd-sysctl.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:65 - ramfs none rw,mode=700
241 120 0:92 / /run/credentials/systemd-tmpfiles-setup-dev.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:66 - ramfs none rw,mode=700
309 120 0:93 / /run/credentials/systemd-tmpfiles-setup.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:105 - ramfs none rw,mode=700
312 120 0:94 / /run/credentials/systemd-vconsole-setup.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:119 - ramfs none rw,mode=700
465 120 0:97 / /run/credentials/console-getty.service ro,nosuid,nodev,noexec,relatime,nosymfollow shared:211 - ramfs none rw,mode=700

Does systemctl mask systemd-tmpfiles-clean.service survives shutdown? because I need to run wsl --shutdown Arch in order to reproduce the problem.

OneBlue commented 5 days ago

Here's probably what's causing the issue:

168 82 0:86 / /tmp rw,nosuid,nodev - tmpfs tmpfs rw,nr_inodes=1048576

There something that's mounting a tmpfs over /tmp, which masks the files in there. Can you share the output of:

systemctl -t mount

?

LeonardoMor commented 4 days ago

Here's probably what's causing the issue:

168 82 0:86 / /tmp rw,nosuid,nodev - tmpfs tmpfs rw,nr_inodes=1048576

There something that's mounting a tmpfs over /tmp, which masks the files in there. Can you share the output of:

systemctl -t mount

?

❯ systemctl -t mount
  UNIT                                                                       LOAD   ACTIVE SUB     DESCRIPTION
  -.mount                                                                    loaded active mounted Root Mount
  dev-hugepages.mount                                                        loaded active mounted Huge Pages File System
  dev-mqueue.mount                                                           loaded active mounted POSIX Message Queue File System
  init.mount                                                                 loaded active mounted /init
  mnt-c.mount                                                                loaded active mounted /mnt/c
  mnt-wsl.mount                                                              loaded active mounted /mnt/wsl
  mnt-wslg-distro.mount                                                      loaded active mounted /mnt/wslg/distro
  mnt-wslg-doc.mount                                                         loaded active mounted /mnt/wslg/doc
  mnt-wslg-versions.txt.mount                                                loaded active mounted /mnt/wslg/versions.txt
  mnt-wslg.mount                                                             loaded active mounted /mnt/wslg
  proc-sys-fs-binfmt_misc.mount                                              loaded active mounted Arbitrary Executable File Formats File System
  run-credentials-console\x2dgetty.service.mount                             loaded active mounted /run/credentials/console-getty.service
  run-credentials-systemd\x2djournald.service.mount                          loaded active mounted /run/credentials/systemd-journald.service
  run-credentials-systemd\x2dsysctl.service.mount                            loaded active mounted run-credentials-systemd\x2dsysctl.service.mount
  run-credentials-systemd\x2dsysusers.service.mount                          loaded active mounted run-credentials-systemd\x2dsysusers.service.mount
  run-credentials-systemd\x2dtmpfiles\x2dsetup.service.mount                 loaded active mounted run-credentials-systemd\x2dtmpfiles\x2dsetup.service.mount
  run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev.service.mount          loaded active mounted run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev.service.mount
  run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev\x2dearly.service.mount loaded active mounted run-credentials-systemd\x2dtmpfiles\x2dsetup\x2ddev\x2dearly.service.mount
  run-credentials-systemd\x2dudev\x2dload\x2dcredentials.service.mount       loaded active mounted run-credentials-systemd\x2dudev\x2dload\x2dcredentials.service.mount
  run-credentials-systemd\x2dvconsole\x2dsetup.service.mount                 loaded active mounted run-credentials-systemd\x2dvconsole\x2dsetup.service.mount
  run-lock.mount                                                             loaded active mounted /run/lock
  run-shm.mount                                                              loaded active mounted /run/shm
  run-user.mount                                                             loaded active mounted /run/user
  sys-fs-fuse-connections.mount                                              loaded active mounted FUSE Control File System
  sys-kernel-debug.mount                                                     loaded active mounted Kernel Debug File System
  sys-kernel-tracing.mount                                                   loaded active mounted Kernel Trace File System
  tmp-.X11\x2dunix.mount                                                     loaded active mounted /tmp/.X11-unix
  tmp.mount                                                                  loaded active mounted Temporary Directory /tmp
  usr-lib-modules-5.15.153.1\x2dmicrosoft\x2dstandard\x2dWSL2.mount          loaded active mounted /usr/lib/modules/5.15.153.1-microsoft-standard-WSL2
  usr-lib-modules.mount                                                      loaded active mounted /usr/lib/modules
  usr-lib-wsl-drivers.mount                                                  loaded active mounted /usr/lib/wsl/drivers
  usr-lib-wsl-lib.mount                                                      loaded active mounted /usr/lib/wsl/lib

Legend: LOAD   → Reflects whether the unit definition was properly loaded.
        ACTIVE → The high-level unit activation state, i.e. generalization of SUB.
        SUB    → The low-level unit activation state, values depend on unit type.

32 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
OneBlue commented 4 days ago

This is probably the unit that's causing this behavior:

  tmp.mount                                                                  loaded active mounted Temporary Directory /tmp

Does running systemctl mask tmp.mount, followed by wsl --shutdown resolve the issue ?

LeonardoMor commented 3 days ago

This is probably the unit that's causing this behavior:

  tmp.mount                                                                  loaded active mounted Temporary Directory /tmp

Does running systemctl mask tmp.mount, followed by wsl --shutdown resolve the issue ?

Tested this. This does not fix the issue.

suiryc commented 1 day ago

Hello,

Is your systemd version 256(.2-1) ? It seems systemd behaviour changed since version 255, somehow as if we are logged in the WSL instance before systemd is actually fully ready/started.

Maybe related, a systemd ticket that was closed as "WSL issue": https://github.com/systemd/systemd/issues/33483

Unexpectedly, when I enable the experimental autoMemoryReclaim setting (windows-side WSL configuration in .wslconfig), the issue does not appear to happen:

[experimental]
autoMemoryReclaim = gradual

Alternatively as a temporary workaround, you may try to revert to systemd 255 to confirm this is due to the 256 version.

LeonardoMor commented 1 day ago

Indeed:

systemd 256 (256.2-1-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBCRYPTSETUP_PLUGINS +LIBFDISK +PCRE2 +PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK +XKBCOMMON +UTMP -SYSVINIT +LIBARCHIVE

Where is this .wslconfig file?

suiryc commented 1 day ago

In the user home directory (%UserProfile%), e.g. C:\Users\your-user-name. By default the file is not there (all parameters have default values), so the first time you want to set a specific setting value, you have to create the file in this directory.

There are some details here.

Edit: it is important to note that, as explained in the doc, you usually have to shutdown the WSL (wsl --shutdown) and then restart the WSL instance for the changes to take effect

LeonardoMor commented 1 day ago

This resolves the issue.

suiryc commented 1 day ago

Glad to hear this also works for you. I don't know what is exactly the underlying issue between WSL 2 and systemd 256. Fixing it this way seems more like an unexpected side effect of enabling this setting, but at least that's a workaround for now.