WSL2
Disable automatic mounting of Windows disks
WSL automatically mounts Windows disks under /mnt/<drive letter> (e.g., /mnt/c for the C: drive).
If you want to disable this feature, edit ‘/etc/wsl.conf’ in your WSL distribution, adding or modifying the [automount] section:
sudo nano /etc/wsl.conf
[automount]
enabled = false
mountFsTab = false
Notes:
- enabled = false: Stops WSL from automatically mounting Windows drives (such as C:\ at /mnt/c) under /mnt/.
- mountFsTab = false: Prevents WSL from processing
/etc/fstabentries at startup.
Now, restart WSL for the changes to take effect: stop with wsl --shutdown and restart your WSL distribution.
After disabling automount, you will get errors like the following at startup:
wsl: Failed to translate 'C:\WINDOWS\system32'
wsl: Failed to translate 'C:\WINDOWS'
wsl: Failed to translate 'C:\WINDOWS\System32\Wbem'
This is because WSL tries to append your Windows PATH environment variables (like C:\WINDOWS\system32) to your Linux environment by default.
To prevent this, add appendWindowsPath = false to /etc/wsl.conf. Or ignore the errors. : )
[interop]
appendWindowsPath = false
How to map a Windows folder to a WSL folder:
Given the C:\Temp\wsl_ubuntu_share folder on Windows, you can mount it to /mnt/wsl_ubuntu_share in WSL:
sudo mkdir /mnt/wsl_ubuntu_share
sudo mount -t drvfs 'C:\Temp\wsl_ubuntu_share' /mnt/wsl_ubuntu_share/
If you want to make it permanent, reactivate the mountFsTab option in /etc/wsl.conf and add the mapping line to /etc/fstab, then reboot:
[automount]
enabled = false
mountFsTab = true
C:\Temp\wsl_ubuntu_share /mnt/wsl_ubuntu_share drvfs defaults,noatime,uid=1000,gid=1000,umask=022 0 0
A word of caution: if you forget to set mountFsTab = true, in many cases you could find the folder correctly mounted anyway.
This is because systemd is running inside your WSL distribution. Systemd reads and processes /etc/fstab automatically as a core Linux function. But on some reboots, systemd might try to mount your Windows path before the virtual network or Windows filesystems are fully initialized by WSL, occasionally throwing startup warnings like Processing fstab with mount -a failed.
So, always set mountFsTab = true.
Disks
Distributions:
c:>wsl --list --verbose
NAME STATE VERSION
* Ubuntu Running 2
podman-machine-default Stopped 2
Links in the Windows Start Menu:
"C:\Program Files\WSL\wsl.exe" --distribution-id {0cb77e94-...} --cd ~
"C:\Program Files\WSL\wsl.exe" --distribution-id {3aa6735e-...} --cd ~
List disks (the BasePath folder contains the VHDX disk file):
PS C:\>Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss" -Recurse
Name Property
---- --------
{0cb77e94-....... State : 1
DistributionName : Ubuntu
Version : 2
BasePath : C:\Users\XXXXXX\AppData\Local\wsl\{0cb77e94-...}
DefaultUid : 1000
VhdFileName : ext4.vhdx
Flavor : ubuntu
OsVersion : 24.04
{3aa6735e-....... State : 1
DistributionName : podman-machine-default
Version : 2
BasePath : \\?\C:\Users\XXXXXX\.local\share\containers\podman\machine\wsl\wsldist\podman-machine-default
Flags : 15
DefaultUid : 0
VhdFileName : ext4.vhdx
Flavor : fedora
OsVersion : 42
…
tail -f _WorkerFoo.txt --disable-inotify