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  

  3. I'm very happy to search out this information processing system. I would like to thank you for this fantastic read!!
    Docker and Kubernetes Training
    Kubernetes Online Training
    Docker Online Training
    Docker Training


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

WSL + Interop + Azure: $HOME is everywhere

Introduction Microsoft //BUILD is just 3 days away and while I'm just (super) sad that I will not attend, I wanted to bring a "special" gift. After some discussion on Twitter with @Tara_msft , she asked me if I tried Azure Cloud Shell. She past a link to the (incredibly) excellent @docmsft site. And the Pandora box was definitively open... The crazy idea after looking at the Cloud Shell, and reading  about Spot Instant Cloud, this (crazy) idea came to life: What if, I could tweak the "$HOME" hack  and make it available "everywhere"!  Or, due to the limitation of the Azure free account (in terms of storage capacity) and the "Network drives" permissions/behavior, at least I could put the important dot files in the Cloud Drive while keeping the development files on the "Interop zone" (read: /mnt/c/...) as described in Brian's blog post. To be prepared, you must Before we can apply what follows, some preparatio