Support for vaults in Windows Subsystem for Linux (WSL)

I’m not sure how I’d tell the difference, but if I do a wslfetch, I don’t get any indication as to WSL1 or WSL2.

+1
This would add real value. Other tools I’d like to use with my vault (e.g. git-annex) for storing and tracking non-md files in my vault, require symlink functionality not found on native windows filesystems.

VS code is also built on electron and has seamless integration with the WSL2 while running from Windows, which makes me think integration should be possible. Given that there is an open source version of VS code (VS codium) perhaps there is a way to incorporate the right tools for Obsidian to play nice with POSIX files from the Windows side.

I’ve tried installing Obsidian within the WSL2 for Ubuntu, but the typing experience was not smooth enough and the graphics rendered too small for everyday use.

2 Likes

If I understand what you’re looking for, you can do symlinks, hardlinks, and junctions in Windows.

I use a utility to do it, just because it’s easier, as well as having context menu items to copy and paste the link. Here’s an article I found on the topic. I see it being very useful with Obsidian. Symlink Article

Interesting, thanks. But that doesn’t really help with this issue. I’ve actually tried moving directories from the WSL2 to the normal windows filesystem and if there is a linux symlink in there, Obsidian will error out. I just don’t understand why this is the behavior? VS code can simply ignore the symlinks. Why can’t obsidian?

I guess I’m hoping for one of two things (or both):

  1. Obsidian (installed on Windows) can learn to not error out when it encounters a symlink.

  2. Obsidian (installed on WSL2) can show better performance on high DPI monitors. The fonts render way too small and the typing experience is laggy.

If either of these are fixed. I would be so happy.

1 Like

This is a killer for me, too. Please oh please find time to fix this error. :pray::blush:

1 Like

I also get the EISDIR, watch error when attempting to open a vault located within a OneDrive mounted as a network drive

+1 Would appreciate this feature.

Currently on v0.15.9 and am unable to open a vault from the UNC WSL2 mapped drive; receive the same EISDIR error message.

I’m very surprised that this isn’t available yet, I feel like WSL users make up half of the Obsidian user base!

3 Likes

Just want to bump this post. It is something I’d love to see as well. Some of my Obsidian files have names that Windows doesn’t support, so simply copying the files to Windows isn’t an option.

As others have noted, it seems like this should be possible since VSC handles it without issue.

Also bumping +1.
I hoped something will be done with that with last release, but still nothing -.-

Yes please. In meantime, found this script to solve the issue by syncing WSL directory to Windows. GitHub - mikkorantalainen/rsync-continuous: A simple tool to syncronize two directories with low latency.

sh rsync-continuous ~/from /mnt/c/Vault/to
1 Like

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

  1. Launch a terminal with your distro.
  2. Execute sudo nano /etc/wsl.conf.
  3. Add the following to the file (note if the [boot] label already exists, then append systemd=true below it):
    [boot]
    systemd=true
    
  4. Write and close the file.
  5. Now it’s time to add your bind mounts, execute sudo nano /etc/fstab
  6. Add a new line and enter:
    <src> <dest> none defaults,bind,uid=1000,gid=1000,umask=022 0 0
    
    replacing <src> and <dest> with your chosen paths, for example, mine looks like this:
    /mnt/c/Users/PurplProto/Documents/Work\040Notes /home/purplproto/OneDrive/Documents/Work\040Notes none defaults,bind,uid=1000,gid=1000,umask=022 0 0
    
    The keen-eyed will notice the seemingly random \040 in Work\040Notes, this is for escaping spaces, if your paths have spaces in them you must replace spaces with \040.
  7. Write and close the fstab file.
  8. Terminate your distro by opening cmd and executing wsl --shutdown.
  9. Then reopen a terminal with your distro again.
  10. Execute ls -a on your folder, in my case ls -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 :slightly_smiling_face:

3 Likes

I’m also getting this EISDIR error now. How can I remove the WSL2 directory as a Vault from my Windows instance of Obsidian? The GUI app won’t let me do it and I can’t find the global obsidian settings file on my system. I even tried completely deleting & reinstalling Obsidian to no avail.

Hey @pshev, I can’t seem to replicate this behaviour with neither \\wsl.localhost\ nor \\wsl$\ with the latest Obsidian installed on Windows 11 + WSL2. Attached a screenshot of the error observed:

image

An error occurred while loading Obsidian. Error: EISDIR: illegal operation on a directory, watch '\\wsl$\Ubuntu\home\

Despite this, the following boilerplate files are created within a nested “.obsidian” directory of the WSL2 path, just as @pcbowers mentioned:

.obsidian
├── app.json
├── appearance.json
├── core-plugins-migration.json
├── core-plugins.json
└── hotkeys.json

To echo @mgamble, an approach like VS Code would be most appreciated for seamless integration of Obsidian across filesystems, regardless of the host.

+1 Bumping this as well. All my projects are stored in WSL and I would love to be able to have obsidian notes stored with them.

2 Likes

+1 Since I would like to use WSL (2) as well for Obsidian notes.

1 Like

+1 same thing happens with VMware shared folders. Unlike with VirtualBox shared folders (which work with Obsidian), when I attempt to use VMware shared folders, I get the following error…

“An error occurred while loading Obsidian. Error: EISDIR: illegal operation on a directory, watch 'Z:\shared\my-vmware-shared-folder'”

Seems to be the same issue, some dir (or non-OS “filesystem”) where OS support for watching folders is not supported.

In cases where Obsidian cannot use an OS mechanism for monitoring a vault, a less optimum but workable fallback such as intermittent scanning of the vault folders, if at least allowing the app to start, would be better than nothing. (I make no assumptions this is a good or easy workaround to employ… just accentuating my +1)

Thanks!

1 Like

I tried the workaround from @PurplProto and it kind of worked. Her steps didn’t produce the desired result at startup. I had to run sudo mount -a to mount the system.

However, I’ve found another workaround.

The system worked after running these steps:

In fstab (note you have to explicitly mount C: first since we process fstab before automounting DrvFs):

In /etc/fstab

sudo nano /etc/fstab

Add the following lines

C:           /mnt/c         drvfs   rw,noatime,uid=1000,gid=1000,umask=22,fmask=11     0    0
/mnt/c/home/username/your/windows/folder  /home/username/your/ubuntu/folder none    bind                                               0    0

Then shutdown WSL from the windows terminal

wsl --shutdown

Reference: Automount additonal filesystems from fstab · Issue #2636 · microsoft/WSL · GitHub

1 Like

+1 for this.

Created an account just to bump this request

1 Like

Emmm, your can use windows path, After all, they can be found in the /mnt directory of WSL,and WSL have “ln” ,I just did that。

1 Like