-
Notifications
You must be signed in to change notification settings - Fork 822
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
WSL2: VHD Size Limited to 256GB #4373
Comments
Tempting to post a Slashdot meme from late 1990s (canonical use case for needing that much disk space) which most the crowd here probably doesn't remember. But a (more contemporaneously appropriate) dev scenario? Hmm. 400GB is recommended for an Android build, or so I gather. |
Stumbled on this and wanted to post my particular use case. My company makes robots, everyone here is on Windows 10 and our primary target is UWP so Windows 10 is a hard requirement for us. A few of us at our company also work on OS builds for the robot, I'm currently trying to see if I can run an OpenEmbedded build (to see if we can ditch UWP for dotnet core) but ran into the size limitation when I wanted to adjust the kernel. I used LxRunOffline to move WSL 2.0 onto a second SSD in my laptop that has 500 GB of storage. While I may have a use case for this, it does seem like as long as there are instructions on how to resize the VHD, having a single command to resize would help me but I would use it so infrequently that having it as a feature would be extremely low priority for my particular use case. |
Compiling two versions of Android with ccache can easily exceed 256GB |
Here is the real user instance. I'm Xiaomi software engineer. A whole smartphone software code can be more than 150GB easily, sometime I need download several projects and compile them. |
|
How can you reduce the size ? I don't want to have so much space wasted with old data. |
@fungiboletus Same as any other vhdx. |
I agree, users need an option to increase their WSL2 disk size. I myself compile 2 different Android custom ROMS and even 1 can exceed 300gb, not to mention the presence of ccache. So i want to expand it to 700gb, but i just can't, please Microsoft do something with this, I'm using Windows Insider Beta version, is there a wsl option in beta version to do such thing? |
Maybe include LVM so partitions can be resized on-the-go |
@bencetari It's not easy but it's possible to expand the vhdx to 700Gb. Follow these steps: |
the docs did not work for me: Got the following error: Anyone experienced the same? Or found a solution? |
@pmualaba I saw the same error when I tried resizing the wrong device. Try
Make sure /dev/sdc is the device you want to resize. |
Facing the same issue but sadly this URL returns a 404. Trying this: https://docs.microsoft.com/en-us/windows/wsl/vhd-size |
Be sure to completely restart your wsl. |
I got the same error. Solved by runnning |
Sigh... None of the suggested work-arounds work on a WSL2 setup with latest from the store on a WinX machine with 21h2 updates on it (Locked by client administrative control to this...can't upgrade...and if that's your answer, it'll be another LEGIT, "Windows is Crap" observation...) At least I can mount ext4 volumes via WSL2 now...that was missing prior to the upgrade. (Niiice...) It won't let me resize past the default max size here. So, what gives? We're now in Jan of 2023 with this problem being a problem with NO help from Microsoft. So, when the documentation doesn't describe the needed...what do you do? Switch to a VM framework that while it uses the Hyper-X backend, works like it's supposed to and then run docker atop that? |
To resize an ext4 partition within an existing wsl distribution, you need to do 2 things:
Unfortunately, you cannot perform step 2 while the root partition is mounted. So you'll have to do it by attaching the virtual hard disk to another distribution and resizing it there. To resize my Ubuntu distribution's root partition size, I grew the virtual hard disk to 1TB using step 1 above. Then I performed the following steps:
At this point you can start the Ubuntu distribution, and its root partition should be 1TB. |
Heh. I finally arrived at the sequence you gave there.
Took...well...forever. Not as clearly documented as it ought to be. It
has the potential of making Linux stuff less painful for people
that're...well...stuck doing Windows systems and needing to do Embedded
Linux work- which doesn't play nice in the Windows playground.
|
This is still an issue... I have a crashing Debian WSL2 due to the VHD "virtual size" being 1024 GB by default on a system with just 256 GB disk (!). Great job setting the default virtual size guys. 🙄 I have precisely the opposite problem: I want to reduce the virtual size in order to keep it from growing so large that it fills my C: drive. Some ideas:
Seems currently the only solution is to back up my files, delete the WSL ( |
Yes, WSL2 really does need the ability to specify the size of the vhdx file when a new distro is created. There's no good reason to enforce a hard-coded size. The fact that it went from 256GB to 1TB shows it can be changed. It just needs to be exposed to the UI via the I have been able to successfully shrink the vhdx file by using resize2fs first and then making a new vhdx and copying the data at the block level. But not only is this horribly inefficient (it could be scripted to some degree but it's far from ideal) but it also won't persist, and it's useless for situations like Docker Desktop which entirely self-manages the WSL instances. You can do the same with Docker Desktop but even a new Docker version might cause the distro to be rebuilt and your resized vhdx to be trashed. I suppose a sort-of kind-of workaround might be just that - using resize2fs but then not resizing the vhdx. It'll be a larger block device on Linux but no data would ever be written outside the ext4 filesystem's bounds anyway. If Microsoft would at least open source the userspace components and scripts of WSL, perhaps the community could implement this... |
@beevik your guide is best |
The VHD used by WSL2 is created with max size of 256 GB (as described here: https://docs.microsoft.com/en-us/windows/wsl/wsl2-ux-changes#understanding-wsl-2-uses-a-vhd-and-what-to-do-if-you-reach-its-max-size)
When the max size is reached, increasing the VHD size further requires a series of steps as described in the same document.
There are cases when users know that they would need more than 256GB when they are enabling WSL2 and it would be good if they are given an opportunity to make a choice about the max size of their VHD if their preference is different than the default. This should be achievable via an optional command line argument. It would also be great if the max size of the VHD could be controllable via API. Then an engine like Docker for Windows could manage the amount of storage available to run containers without need for a user to go through several manual steps to resize their VHD.
The text was updated successfully, but these errors were encountered: