How to make additional internal SSD visible to Ubuntu 20.04 under WSL2

I have Ubuntu 20.04 running under WSL2 (including XFCE4 via VcXsrv).

I installed an unpartitioned mSATA SSD, and allowed the Windows Disk Management snapin to initialize it as GPT, then added a simple primary partition that wasn't formatted. It shows up in Windows Disk Managment as "Healthy (Basic Data Partition)".

I launched wsl2, launched xfce4, then sudo'ed gparted. There's no sign of the new drive, anywhere.

Is the problem just that I allowed Windows to initialize it as GPT instead of MBR, or is there something deeper I have to do to tell Ubuntu 20.04 (under wsl2) that there's another internal hard drive available for it to format (as BTRFS) and use?

Note: I've seen posts elsewhere that suggest I should use wsl --mount \\.\PHYSICALDISK2, but that won't work for me. wsl --mount requires an insider build of Windows. I'm not, and I won't, so if something has to be done at the Windows level, it's going to have to be something that doesn't depend upon wsl --mount working. That said, this particular drive (and its future BTRFS filesystem) doesn't have to be usable by anything besides Ubuntu 20.04 running under wsl2, so it doesn't matter if I need to temporarily rely on a hack that makes it only visible to Ubuntu under wsl2. I'm going to be using it as my Android AOSP build output directory, so literally everything that will be on it can be automatically regenerated within a few hours.

3

1 Answer

As you've noticed, access to physical drives is a future feature of WSL. Currently, the only way that WSL2 gets access is through the 9P protocol where WSL mounts drives available to Windows (typically auto-mounted under /mnt/<drive letter>).

But, as you are probably aware, using that for a build output under WSL is probably not a good idea, as 9P access is incredibly slow, especially when dealing with many small files.

My recommendation would be to:

  • Format the drive as NTFS and map it to a drive letter under Windows (or create a directory junction elsewhere).

  • Place your actual WSL distribution on that drive so that the virtual ext4 disk under WSL is as a file there. You can do this through the wsl --export and wsl --import commands. See this answer on Stack Overflow for full instructions on how to do this.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like