5

I want to mount my Windows C: Drive to /mnt/c in WSL as a drvfs file system, but if I specify drvfs as the file system type I get a 9p filesystem instead.

I entered these commands:

$ sudo umount /mnt/c
$ sudo mount -t drvfs C: /mnt/c/
$ mount -l
...
C: on /mnt/c type 9p (rw,relatime,dirsync,aname=drvfs;path=C:;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=3,wfd=3)

As you can see type is 9p instead of specified drvfs.

1 Answer 1

9

Yes, when you mount a Windows drive in WSL version 2, it uses the 9P protocol. This is a big change from version 1, which used drvfs. The WSL host runs a 9P server, which the WSL instance connects to.

There are quite a few sites out there discussing this, but they are a bit difficult to find with a search engine, IMHO, since the "bigger" news regarding 9P was that each WSL instance (whether WSL1 or WSL2) also hosts its own 9P server, which the Windows/WSL host can then connect to as a client and provide access to WSL files at the \\wsl$\<distroname> path.

Here's one of the better discussions I found on r/bashonubuntuonwindows. Note the quote from u/benhelioz, one of the WSL developers (now, I believe the team lead):

Great article. I want to be very clear when I say this - We are absolutely not satisfied with our Windows Drive file access performance. This is one of the biggest areas we are investing in and are working hard at improving the performance. One thing I will emphasize is our 9p has some benefits that Samba and SMB do not. It is much more secure, supports admin / non-admin, and is fully compatible with anything people were using DrvFs for in WSL1.

The obvious unanswered part of your question is why can't you mount the drive as drvfs directly. This is because WSL instances do not have direct access to the hardware. They rely on the WSL (LxssManager) service interface to provide API access to Windows elements. So we are dependent on WSL's methods of providing access, which in the case of WSL2 and NTFS drives, is 9P.

4
  • Thank you, for your fast answer! So I could install WSL 1 to do it? Im just trying to run vagrant inside WSL, but it complains about not being executed inside a DrvFs
    – tonik
    Apr 21, 2021 at 16:01
  • While I haven't tried it myself, I've heard of a few issues from other Stack questions running vagrant on WSL (both 1 and 2). The Vagrant team considers the integration to be beta quality, but does provide some instructions/guidance at that link. Are you using those instructions? There might be a way to do it on WSL2 by following that; I'm just not sure. Apr 21, 2021 at 16:15
  • Yeah I tried it, but it didn't work for me: "When Windows access is enabled Vagrant will automatically adjust VAGRANT_HOME to be located on the Windows host. This is required to ensure VAGRANT_HOME is located on a DrvFs file system." For me there was no VAGRANT_HOME Variable set automatically, maybe I have to set it by myself
    – tonik
    Apr 21, 2021 at 16:25
  • Nice answer. :) Apr 21, 2021 at 17:04

You must log in to answer this question.

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