-
Notifications
You must be signed in to change notification settings - Fork 850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement tmpfs file system for /tmp that writes to volatile memory instead of persisting to disk #6999
Comments
Label "feature" loophole, but
That much is dupe #1278 ➡️ #344 (➡️ #994). Fire up |
As almost all linux machine hardening guides suggest, the As per the recommendations here, doing this directly in the .bashrc isn't ideal but works:
I've also added this answer to the only stack overflow question I can find on the matter: https://superuser.com/questions/1170939/simulate-reboot-to-clear-tmp-on-the-windows-linux-subsystem/1656653#1656653 |
/etc/fstab ... this seems to be creating a new /tmp mount for each bash terminal @xploSEoF Liam could you please write how to test it? |
Explicitly delete the lock files before starting wsld following the nbdd0121@c3a2bb7 commit. WSL2 never deletes the tmp directory - microsoft/WSL#6999
Since addition of Systemd this can be easily enabled using instruction from this post https://askubuntu.com/a/1416156/588206:
|
Wow, late reply, sorry. It's simple. Open a terminal, then put a file into the /tmp drive, even with something as simple as There are a number of other ways to confirm, and that could be specific to WSL1 - I'm unfortunately stuck on WSL1 due to using features unavailable on WSL2. |
Indeed you can use either systemd or fstab to use a tmpfs for /tmp. Closing since this is user-configurable. |
Note that currently (WSL 2.2.4.0, and since 2.0.12.0), doing so will break GUI applications, because the new |
@Nahor In the interest of saving others from this unfortunate bad default behaviour who find this GH issue, an easy manual fix is to create
and then This results in the symlink being created, and it happens after tmpfs is mounted by systemd. |
Thanks so much for the snippets. Maybe off-topic, but should this be included in the distribution provided by Microsoft Store for future fix? |
thanks, this works. |
@darkvertex Wonderful tip, thank you! I find it a bit odd that with systemd the |
Does this mean that tmpfs has a real implementation now (actually in RAM)? I'm aware the implementation was simply faked as of 2017, but I would appreciate proper confirmation regarding any changes. |
Is your feature request related to a problem? Please describe.
I'd love to be able to use /tmp like I would on linux machines, as a tmpfs file system. At the moment the tmpfs file system on WSL 2 is actually implemented by mapping it to disk instead of writing to RAM. This results in files not being cleaned with restarts (e.g.
wsl --shutdown
) that accumulate over time. Furthermore, this can result in performance issues with code that relies on temp files since they will be actually written to disk.Describe the solution you'd like
Implement the tmpfs by writing to volatile memory
Describe alternatives you've considered
At least autoclean /tmp in the meantime at the startup of the distro instead of relying on the user to do it.
The text was updated successfully, but these errors were encountered: