Skip to content
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

Disk file ext4.vhdx takes too much space #372

Closed
FoliageOwO opened this issue Jul 19, 2024 · 2 comments
Closed

Disk file ext4.vhdx takes too much space #372

FoliageOwO opened this issue Jul 19, 2024 · 2 comments

Comments

@FoliageOwO
Copy link

Hi. I'm new to playing with a WSL. I've used the ArchWSL for a while, but I found my disk almost full when installing stuff.

After running gdu -i /mnt in the ArchWSL, it told me the WSL only used 18.4 GiB:

image

But the disk file occupies 50+ GiB:

image

Environment:

  • Windows build number: 10.0.22631.3737
  • Security Software: Windows Defender
  • WSL version 1/2: WSL 2.2.4.0
  • ArchWSL version: 24.4.28.0
  • ArchWSL Installer type: zip
  • Launcher version: 24042000

Additional context
Seemed to have a connection with this issue WSL#8226, for which I did Optimize-Vhd /path/to/the/ext4.vhdx on my PowerShell, and it threw me an error:

Optimize-VHD: Failed to compact the virtual disk.

Failed to open attachment '/path/to/the/ext4.vhdx'. Error: 'The requested operation could not be completed due to a virtual disk system limitation.  Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.'.

I followed the instructions of the reply on the issue WSL#4103, which did nothing.

Is the space the disk file takes normal, or my settings for ArchWSL is wrong?

@lucasacoutinho
Copy link

Hi @FoliageOwO, I’m not sure if you still need help, but I recently faced the same issue, so I thought I'd share my solution for anyone else encountering it.

My distro was set to sparse for a while, which caused some complications. I resolved it by running:

wsl --manage <distro> --set-sparse false

After doing this, I was able to use optimize-vhd without any issues. Once you're done, you can re-enable sparse mode if you like, but I recommend running this process periodically—especially if you notice an unusually large disk usage.

For reference, I’m using the default Ubuntu distro, but this solution should also work for ArchWSL and others.

@FoliageOwO
Copy link
Author

@lucasacoutinho Thanks, this really does work! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants