Skip to main content

WSL: One Home to host them all


This blog post will explain how a single home mount can be shared accross all the WSL instances.
It was quite fun to find the idea and then make it happen.
It will use all the tools currently available from WSL, so please don't expect a "Linux only" as Interopability will be heavily used.
And before I start, here is my point of view about WSL: It's not only Linux!
It's different, just like GNU is different from Unix (yes I said it).
We have finally the strength of both worlds combined. And while I do understand the "dev" aspect is meant to be reproducible in a Linux prod environment, the "ops" side is meant to take advantages of everything that can make the full environment feeling Home.

Setup requirements

In order to really enjoy this solution, I do recommend having 2 or more WSL distros installed or, if you fell like a real WSLCorsair, try @bketelsen crazy setup (I love it)!

While the distros are downloading, let's prepare the Windows side (read: Interopability) of the solution:
  • Create a folder in any physical drive (C, D, X, ...) and give it a nice name (i.e. home)
  • Right click on it and choose "Properties" option
  • Click on the "Sharing" tab
  • Click on "Share" button
    • Normally, your login name and "Everyone" should be listed
  • Remove "Everyone" from the list, keeping only your login name
  • Click the "Share" button
  • Back on the "Sharing" tab, you will now see the Network path of your folder
    • It will look like: \\<computer name>\<folder name>
  • Close the "Properties" window 

Once the directory is shared, what we will do is "map it" as a new drive in Windows explorer:
  • In Windows Explorer, click on "This PC"
  • Click on the top menu "Computer" and click on "Map network drive"
  • Pick a "Drive" letter (i.e. H:)
  • Write the "Network path" in the "Path" textbox
  • Ensure "Reconnect at sign-in" is checked
  • Click on the "Finish" button

Setting up our new Home

Finally, we will be able to mount our "home drive" and thanks to this gem called WSLconfig, it will be possible to mount automatically every time a new terminal is opened (with a little help as described below):
Open a terminal of your favorite distro (i.e. Ubuntu)
PS client> ubuntu.exe
[Optional] Edit the sudoers file to be password less for your account
client:~$ sudo visudo
<username> [tab] ALL=(ALL:ALL) [tab] NOPASSWD: ALL

WSLconfig needs a config file to be created "inside" the distro
client:~$ sudo vi /etc/wsl.conf
# Enable extra metadata options by default
enabled = true
options = "metadata,umask=22,fmask=11"
mountFsTab = true

# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
generateHosts = true
generateResolvConf = true

In the config file, we enable the "fstab" to be read when the terminal is launched, so the next step is setup the Home mount point in it
client:~$ sudo vi /etc/fstab
H:      /home   drvfs   rw,noatime,uid=1000,gid=1000,umask=22,fmask=11      0       0

If you close the terminal now and launch a new one, unfortunately the "fstab" is not read and the "home" filesystem is not mounted. Here is a small hack how to do it (for all users)
client:~$ sudo vi /etc/bash.bashrc
sudo mount -a && cd

The "mount -a" will mount all the filesystems listed in "fstab"
And because we are already logged in, we need to "move" in the mounted filesystem by simply doing a "cd"
And now, repeat for the other distros and you will get a single home for all your WSL instances:


as the now the "home" filesystem is mounted as the "windir" (i.e. /mnt/c), you are free (to be confirmed by the WSL team) to edit the files in it with Windows programs (Interopabilitiy).
So if you have VSCode installed on your Windows instance, then you can simply do
client:~$ code mySourceCodes/hat.go
Enjoy and let me know in Twitter if this solution helps you and/or if you came with your own solution.

>>> Nunix Out <<<


  1. It's missing a step to copy your *existing* /home/user stuff into the mounted home. Otherwise AweSOME! I'm trying it now.

    1. ohhh a reply, sorry was not even awaiting one :) ... but you shared it in your blog post which is way better, but thanks, I will correct it

  2. I must be missing something because those mount options fail with bad superblock... in fstab or command line... without any mount options it mounts but obviously as root:root

     chris  /  mnt  sudo mount -t drvfs -o rw,uid=1000,gid=1000,umask=22,fmask=11 H: /mnt/h
    mount: wrong fs type, bad option, bad superblock on H:,
    missing codepage or helper program, or other error

    In some cases useful info is found in syslog - try
    dmesg | tail or so.
     chris  /  mnt  sudo mount -t drvfs -o rw,umask=22,fmask=11 H: /mnt/h
    mount: wrong fs type, bad option, bad superblock on H:,
    missing codepage or helper program, or other error

    In some cases useful info is found in syslog - try
    dmesg | tail or so.
     chris  /  mnt  sudo mount -t drvfs H: /mnt/h
     chris  /  mnt  


Post a Comment

Popular posts from this blog

Docker + WSL: Get 2 daemon for the price of 1

Introduction almost two years ago, Docker announced the capability of switching between the Linux and Windows containers "mode" (far from the right click that we have today). At that time, I wrote a blog post on how to run both daemons at the same time ( ) Fast forward to 2018, and while we were blogging on how to get the TLS connection from WSL docker client with  Rory McCune  ( ), another blog post, by Stefan Stranger drew my attention (read: blew my mind) as I was trying to reproduce the same: how could I "bind" the docker socket in WSL with the Docker for Windows Linux mode socket ( ) From 1 to 2 daemon: DemonHunter mode achieved Now that we have all the required setup resources, let's b

Secure nested LCOW: Part 3

Part 3: Getting all together After the configuration of the Docker daemon on the Nested Hyper-V VM ( part 2 ), it's now finally time to configure the Docker client that will connect to it. Once again, I will be using WSL as the main shell. However, if you choose to go with Powershell, it's OK too (simply I won't explain it here :). Setup: Window 10 Docker Client first of all, the docker client needs to be installed in the WSL environment. And this will be as easy as one command line, thanks to the Docker install script: client:~$ curl -sSL | sudo sh As the end of the log suggests, add your user to the docker group. This will require you to logoff in order to apply the change. You can either close the WSL console window and open a new one (logoff / login), or a small trick is to "login again" using the "su" command: client:~$ sudo usermod -aG docker $LOGNAME client:~$ sudo su - $LOGNAME Generate Docker client