TechBuzzPro

Mount Windows Folders in WSL Automatically on Startup

· 6 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step‑by‑Step
  3. Mount several Windows directories at WSL startup
  4. Common Mistakes
  5. Tips
  6. Troubleshooting
  7. Frequently Asked Questions

Yes—you can have Windows directories automatically mounted in WSL each time the distribution starts by adding the appropriate entries to /etc/fstab or by creating a small launch script that runs at login.

What You'll Need

  • Windows 10 version 1903 or later (or Windows 11) with the Windows Subsystem for Linux feature enabled.
  • A Linux distribution installed from the Microsoft Store (Ubuntu, Debian, Kali, etc.).
  • Administrative privileges on the Windows host (required to edit /etc/fstab and to set up a startup task).
  • Basic familiarity with the Bash shell and a text editor such as nano or vim.

Step‑by‑Step

  1. Confirm that the drive you want to mount is accessible from WSL. Open your WSL terminal and run ls /mnt. You should see entries like c, d, etc. If the drive you need is not listed, make sure the drive is mounted in Windows and that the WSL integration option is enabled in Settings > Privacy & Security > For developers > WSL (labels may differ slightly by version).
  2. Create a mount point inside the Linux file system. Choose a location under /mnt or any other directory you prefer. For example, to mount C:\Projects as /mnt/projects, run:
    sudo mkdir -p /mnt/projects
    The -p flag ensures the directory is created if it does not already exist.
  3. Test a manual mount command. Use the mount utility with the drvfs file‑system type:
    sudo mount -t drvfs C:\Projects /mnt/projects
    After the command finishes, ls /mnt/projects should list the Windows folder contents. If you receive a permission error, add the metadata or uid=1000,gid=1000 options as needed (replace 1000 with your Linux UID/GID).
  4. Make the mount persistent with /etc/fstab. Open the file with a text editor:
    sudo nano /etc/fstab
    Add a line that follows the pattern:
    C:\Projects /mnt/projects drvfs defaults 0 0
    You can also add optional flags such as metadata (to enable Linux permissions) or uid=1000,gid=1000 (to force ownership). Example with metadata:
    C:\Projects /mnt/projects drvfs defaults,metadata 0 0
    Save the file (Ctrl+O, Enter, Ctrl+X in nano).
  5. Verify the fstab entry works without reboot. Run:
    sudo mount -a
    If no error appears, the entry is syntactically correct. Check the mount point again with ls /mnt/projects.
  6. Configure WSL to run the mount at every launch. By default, WSL reads /etc/fstab on each start, but some users disable this behaviour via the .wslconfig file. Ensure you do not have enabled = false under the [automount] section. If the file exists, edit it:
    notepad $env:USERPROFILE\.wslconfig
    and either remove the enabled line or set it to true.
  7. Optional: Use a launch script for more complex scenarios. If you need to mount multiple folders with different options, create a script, for example ~/mount-windows.sh:
    #!/bin/bash
    

    Mount several Windows directories at WSL startup

    sudo mount -t drvfs C:\Projects /mnt/projects -o metadata sudo mount -t drvfs D:\Data /mnt/data -o uid=1000,gid=1000
    Make it executable:
    chmod +x ~/mount-windows.sh
    Then add it to your WSL profile (~/.bashrc or ~/.profile) with the line:
    ~/mount-windows.sh
    This ensures the script runs each time a new interactive shell starts.
  8. Restart WSL to confirm everything works. In a Windows PowerShell window, execute:
    wsl --shutdown
    Then reopen your Linux distro. The mount point should be present immediately without manual intervention.

Common Mistakes

  • Using backslashes inside /etc/fstab without escaping them. Windows paths must be written exactly as C:\Folder, not C:/Folder.
  • Omitting the drvfs file‑system type; the default type will be ext4 and the mount will fail.
  • Adding the mount line to /etc/fstab but having automount.enabled = false in .wslconfig, which prevents WSL from processing the file.
  • Running the mount command without sudo, which yields a “permission denied” error for non‑root users.
  • Setting the mount point inside a directory that already contains files; the mount will hide existing files and can cause confusion.

Tips

  • Use the metadata option if you need Linux‑style permission bits on Windows files. This makes chmod and chown behave as expected.
  • When mounting a drive that contains spaces (e.g., C:\My Documents), quote the path in /etc/fstab:
    "C:\My Documents" /mnt/mydocs drvfs defaults 0 0
  • If you share the same Windows folder between multiple WSL distributions, use the same mount point in each distro to avoid duplicate mounts.
  • For read‑only mounts (e.g., when you only need to view logs), add the ro flag: C:\Logs /mnt/logs drvfs ro 0 0.
  • Keep your WSL version up to date (run wsl --update) because newer releases improve drvfs performance and add new mount options.

Troubleshooting

If the folder does not appear after a reboot, follow these checks in order:

  1. Restart both Windows and WSL. A simple power‑cycle clears transient mount issues.
  2. Verify the /etc/fstab syntax. Run sudo mount -a manually; any error message points to a line problem.
  3. Check the .wslconfig file. Ensure the [automount] section does not disable processing. If the file does not exist, create it with:
    [automount]
    enabled = true
    
  4. Confirm the Windows path exists. Open a Command Prompt and run dir "C:\Projects". If Windows cannot see the folder, WSL cannot mount it either.
  5. Inspect permissions. If you receive “permission denied”, add uid=1000,gid=1000 (or your actual UID/GID) to the mount options.
    C:\Projects /mnt/projects drvfs defaults,uid=1000,gid=1000 0 0
  6. Look for conflicting mounts. Use mount | grep /mnt/projects to see if another mount is already occupying the point.
  7. Update WSL. Run wsl --update from PowerShell, then repeat the shutdown/startup cycle.
  8. Review Windows Defender or third‑party security software. Some antiviruses block the drvfs driver; temporarily disable them to test.

If none of the above resolves the issue, consider removing the problematic line from /etc/fstab and using a launch script instead, as scripts provide more granular error handling.

Frequently Asked Questions

Can I mount a network share (e.g., \SERVER\share) automatically?

Yes. Map the share to a drive letter in Windows first (e.g., Z:), then add an fstab entry for Z: just like any local drive.

Do I need admin rights to edit /etc/fstab?

Editing /etc/fstab requires root privileges inside WSL, which you obtain with sudo. No additional Windows admin rights are needed unless you modify .wslconfig.

Why does my mount disappear after I close the terminal?

Mounts defined in /etc/fstab persist for the lifetime of the WSL instance, not per‑terminal. If you shut down WSL (e.g., wsl --shutdown) the mounts are re‑created on the next start. If you only close the terminal window, the instance stays alive and the mount remains.

Can I set different mount options for different folders?

Absolutely. Each line in /etc/fstab can have its own comma‑separated option list, allowing you to mix ro, metadata, uid, etc., per folder.

Is there a performance penalty for using drvfs?

Access speed is comparable to native Windows file access. Using the metadata option adds a small overhead for permission translation, but for typical development work the impact is negligible.

What if I want the mount to be read‑only for security?

Add the ro flag in the fstab line. Example: C:\Secrets /mnt/secrets drvfs defaults,ro 0 0. This prevents any write operations from the Linux side.