GithubHelp home page GithubHelp logo

compact-wsl2-disk's Introduction

WSL2 Compacter ๐Ÿ—œ

A small script for Windows 10 Home users to compact their WSL2 disks

Inspired by this post on GitHub about WSL2 filling hard disks. This script will:

  • Find your vhdx file(s) in the default paths of
    • WSL2 distros (C:\Users\<NAME>\AppData\Local\Packages\CanonicalGroupLimited...)
    • Docker WSL2 distros (C:\Users\<NAME>\AppData\Local\Docker)
    • Any other folder defined via the WSL_FOLDERS environment variable. For having multiple directories, format it as $PATH, as in: C:\PATH\TO\FOLDER1;D:\PATH\TO\FOLDER2;...
  • Shut down WSL2
  • Compact all found disks with diskpart

After that just open another Linux terminal and WSL2 will restart automatically.

Warning

  1. I am a strange man on the internet asking you to run a powershell script. You should probably look inside the script compact-wsl2-disk.ps1 and make sure you understand what it does.

  2. This will stop WSL. So save your work in Linux.

Usage

Open Powershell as Administrator and run:

powershell.exe .\compact-wsl2-disk.ps1

PRs are welcome!

Please file pull requests instead of just asking for things. Thanks!

License

MIT

Thanks

This person on StackOverflow and everyone on the WSL GitHub and R0Wi.

compact-wsl2-disk's People

Contributors

erevrav avatar grische avatar itachisan avatar mikemaccana avatar r0wi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compact-wsl2-disk's Issues

assumes the current user has admin rights

The script doesn't work if the Admin account is different from the current one because it uses %LOCALAPPDATA%.
This is of course unusual for Home users but if you have an idea how to get the vhdx paths anyway let me know.

Clarify that login for default WSL2 distro may be required

If the default distro is set to one with a password-protected account,

 - Found n VHDX file(s)
 - Shutting down WSL2
[sudo] password for USERNAME:

will show up(n and USERNAME are substitutions for actual values).
It'll be useful to mention this behavior in the Readme.

Side Note: I am not sure if this happens with distros that aren't set as default, but I have no plans to check this behavior in that setting.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.