Score:0

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

id flag

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.

Nmath avatar
ng flag
*"a simple primary partition that wasn't formatted"* - if you don't format, there is no file system and no way to use the drive. You must format the partition and choose a file system
Bitbang3r avatar
id flag
That was the point of running gparted under wsl2:ubuntu2004... to create the filesystem. The problem was, the dropdown in gparted that shows the partition'able drives doesn't have an entry for it. And based on what NotTheDr01ds said, it looks like it won't, anytime soon :-(
Nmath avatar
ng flag
Well, no, you are not going to be able to make these kinds of hardware changes through WSL because of the limitations of WSL. If you want to format a physical disk using Linux/Ubuntu tools, you will need to boot Ubuntu from a live session. A live session of Ubuntu is truly Ubuntu and runs on your hardware. You can then use `gparted` or Disks to format the disk and create a file system. The next time you use WSL, you can mount the file system. The current reason you cannot mount the file system is because a file system has not been created
Score:0
vn flag

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.

Bitbang3r avatar
id flag
Ugh. Given the age of some of the posts I found saying that it required an 'insider' build (late 2019), I was hoping that BY NOW, someone had found a way to hack around it (or maybe wrote a script so I could sacrificially install a throw-away copy of 'insider' Windows 10 on another partition, copy off the 3 or 4 files --mount actually REQUIRES, blow it away, then copy them into my 'real' Windows (along with the necessary registry updates) to make it work without having to go all the way and suffer daily thereafter with a flaky 'insider' build.
muru avatar
us flag
@Bitbang3r where did you see this in 2019? All the earliest references I can find are from after [September 10, 2020](https://devblogs.microsoft.com/commandline/access-linux-filesystems-in-windows-and-wsl-2/).
NotTheDr01ds avatar
vn flag
I agree with @muru. It seems like we've been waiting a while for this feature, but it's really "only" been about 9 months now. Currently, WSL releases are tied to a Windows release, and we expect this (and the WSLg functionality) to be in the 21H2 release (a.k.a. Windows 11?). The good news is another new feature is the `wsl --update` option, to allow for WSL releases without the need to tie it to a full Windows release. At least, that's what they are using in the Preview builds to update to WSLg -- Hopefully that continues to be the case to allow faster, decoupled releases in the future.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.