1

Referencing this thread: Where is WSL located on my computer?

I am brand new to Ubuntu, and Linux, and plan to teach myself rudimentary web development. I have a laptop running Windows 11 and I am planning to install a stable version of Ubuntu via WSL2.

Based on what I have read, if you work on files on the Windows C drive, from Ubuntu running via WSL2, the experience is so slow as to be untenable.

Therefore I plan to keep my various programming files on the Linux/Ubuntu file Explorer, for speed purposes.

What I would like to know is this; Do I need to partition my hard drive to set aside space for the "Ubuntu" section?

I.e. If I keep files in the Ubuntu/Linux file explorer system, will I need to set aside/allocate a certain amount of disk space for Ubuntu, and its file explorer, whilst the remainder of my hard drive is allocated for Windows?

Is allocating the disk space part of the WSL2 set-up? Or is there no need and I can keep as many files on the Linux file explorer system as my hard drive can fit?

I.e. Are the Windows and Linux file explorers designed to share the whole hard drive without need for partitioning?

1 Answer 1

2

Do I need to partition my hard drive to set aside space for the "Ubuntu" section?

No, WSL2 automatically creates the virtual disk (ext4.vhdx) for you in the location referenced in my answer to the question you linked to (see the section "Where is your WSL Ubuntu instance?")

There is no need (or ability) to partition this virtual drive. It will be one single partition.

Are the Windows and Linux file explorers designed to share the whole hard drive without need for partitioning?

Well, not quite. The virtual disk that WSL2 creates for any distribution, including Ubuntu is:

  • a max size of 250GB in GA releases, 1TB in the latest WSL Preview

  • Sparse -- This means that it starts out using only as much space on the Windows drive as the files inside Ubuntu take up. It's usage on the Windows drive will expand (up to the max size above) as you add files in Ubuntu.

    However, note that it won't then shrink as you remove files. See this Super User answer for more details on how to recover unused space from the .vhdx if needed.

Your next natural question would likely be "What if I need more than 250GB for my files in Ubuntu?"

In that case, while I haven't done it myself, you could increase the size of the ext4.vhdx using these Microsoft instructions.

Or, if you are on Windows 11, you can install the latest WSL Preview from the Microsoft Store. Note that it won't change already installed distributions, but new distributions will default to a max size of 1TB.

5
  • I was sincerely hoping you'd be the one to answer this and thank you for such a comprehensive answer. Especially the part about being able to increase the size of the Ubuntu instance beyond 250Gb, really sets my mind at ease. Jul 21, 2022 at 14:40
  • @davelangham Most certainly. Since you were talking about potential partitioning and sharing space with Windows, I figured there was a good possibility that you might be doing something in WSL that used a lot of disk space. Jul 21, 2022 at 20:21
  • @davelangham When you get a chance, please consider Accepting the answer, so that it gets closed out. Thanks! Jul 21, 2022 at 20:22
  • I checked the tick next to your answer and it turned green; Will that close it out? I'm new to StackOverflow. Jul 23, 2022 at 5:25
  • @davelangham That's exactly it - Thanks! And welcome to Stack! "Accepting" at least lets folks know that there's an answer that solved your particular question. That way they don't look at thinking it still needs to be answered. However, the answer could change in the future, and someone else may come along and provide more information or a better answer. In that case, you can always choose to accept there's instead. Jul 23, 2022 at 12:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .