I initially created an account just to +1 this feature request, however, there’s actually a relatively simple workaround we can do which does not involve complex scripts or rsync
etc… If you’re in Windows 11 and using WSL2. We can use a bind mount!
My goal was to store my notes in /home/purplproto/OneDrive/Documents/Work Notes
in WSL so I could have them backed up since I try to keep work and personal stuff separate where possible and all my work-related things are already in this WSL instance, so it just made sense to store my notes here as well.
Let’s get into the steps to achieve this.
Config
First, I’ll start with my system configuration because this matters. Running automount for fstab entries seems to be inconsistent across different versions of Windows and WSL.
- OS: Windows 11 22H2
- WSL version: 1.0.0.0
- Distro: Ubuntu
- Distro WSL version: 2
You can find your WSL version by running wsl --version
and the WSL version your distro uses with wsl -l -v
in cmd.
If your versions match here, or are higher, you should be able to safely move onto the setup section, or else keep reading this section first.
If your WSL version number is below 0.67.6
, then you should update to the new Windows store release of WSL by opening cmd and running wsl --update
(note this might only work on Win11, I can’t confirm this). After doing so, you’ll need to shutdown WSL, this can be done using wsl.exe --shutdown
in cmd. We need this update so we can enable systemd
, since the old method of enabling mountFsTab
in the /etc/wsl.conf
file no longer appears to work, at least when attempting to mount Windows directories with my current configuration.
Setup
- Launch a terminal with your distro.
- Execute
sudo nano /etc/wsl.conf
. - Add the following to the file (note if the
[boot]
label already exists, then appendsystemd=true
below it):[boot] systemd=true
- Write and close the file.
- Now it’s time to add your bind mounts, execute
sudo nano /etc/fstab
- Add a new line and enter:
replacing<src> <dest> none defaults,bind,uid=1000,gid=1000,umask=022 0 0
<src>
and<dest>
with your chosen paths, for example, mine looks like this:
The keen-eyed will notice the seemingly random/mnt/c/Users/PurplProto/Documents/Work\040Notes /home/purplproto/OneDrive/Documents/Work\040Notes none defaults,bind,uid=1000,gid=1000,umask=022 0 0
\040
inWork\040Notes
, this is for escaping spaces, if your paths have spaces in them you must replace spaces with\040
. - Write and close the fstab file.
- Terminate your distro by opening cmd and executing
wsl --shutdown
. - Then reopen a terminal with your distro again.
- Execute
ls -a
on your folder, in my casels -a "~/OneDrive/Documents/Work Notes"
and you should see your.obsidian
folder in there.
If you would like to add any more vaults, re-run steps 5 through 7 and then sudo mount -a
which will mount them immediately. We only needed to restart on step 8 instead since we had updated the /etc/wsl.conf
file.
Non-systemd method
Bind mounts should also be achievable on older WSL versions and possibly distros running under WSL1. If you for whatever reason are on those versions and can’t update, then you could try something like:
mount --bind "/mnt/c/Users/PurplProto/Documents/Work Notes" "/home/purplproto/OneDrive/Documents/Work Notes"
If this works for you, then you could just add that command to the bottom of your .bashrc
file.
Hope this helps some folks