$ | >

Mount filesystems permanently from /etc/fstab

It's great that I can mount file systems or USB devices through drvfs but these mounts don't persists when all Linux shells are closed.
How does one mount filesystems permanently, say through /etc/fstab ?
Surely it shouldn't be necessary to manually mount filesystems after the last Linux shell has been closed and a new is invoked.

58 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Robert Oeffner shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    3 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • WSLUser commented  ·   ·  Flag as inappropriate

        Also just realized since this is also through preventing a shell from killing the mount, consider creating a background task (available since 17046). But if you're looking for an automount, that isn't in place yet. The closest you get is using fstab loading as you open a session.

      • WSLUser commented  ·   ·  Flag as inappropriate

        So wsl.conf is your friend you know. /etc/fstab is now fully supported with Insider build 17093. So you can either manually add fstab entries or you can use the new wsl.conf to do the work for you and do a few other things too with your mounts (adding the extended metadata attribute for example.)

        If I were MS, I'd consider this ask as completed.

      • John Cowan commented  ·   ·  Flag as inappropriate

        You can effectively accomplish this by writing a .bash_login script in your home directory something like this:

        if [ ! -e winhome/NTUSER.DAT ]
        then sudo mount --bind /mnt/c/Users/John\ Cowan winhome
        sudo -k
        fi

        Just replace the mount command by whatever mount commands you want, and the file "winhome/NTUSER.DAT" with a filename that will reliably exist if your mounts are in place. Then the first Linux window will require you to type your Linux password, but later windows will not. (I use this one to mount my Windows home directory under Linux.)

      Feedback and Knowledge Base