I'm trying to mount a windows share (SMB/CIFS) using a Debian 10 linux distribution running on Windows 10's Subsystem for Linux using fstab to automount on startup. My software specs are
OS: Windows 10 Pro 21H2 OS Build: 19044.1526 Windows Subsystem for Linux 2 (WSL2) Distribution: Debian 10.11
According to the following article by Microsoft, you can create a text file at
/etc/wsl.conf to store user configuration settings for WSL2.
I started using wsl.conf to set the mountFsTab key to true. That should ensure that WSL processes the fstab file. I know the setting should not matter because it defaults to true, but I wanted to make sure it was set to true. My wsl.conf file currently looks like:
# Automatically mount Windows drive when the distribution is launched. [automount] # Automatically mount the fixed drives (C:) under /mnt. enabled = false # Sets the `/etc/fstab` file to be processed when a WSL distribution is launched. mountFsTab = true # Network host settings that enable the DNS server used by WSL 2. This example changes the hostname, sets generateHosts to false, preventing WSL from the default behavior of auto-generating /etc/hosts, and sets generateResolvConf to false, preventing WSL from auto-generating /etc/resolv.conf, so that you can create your own (ie. nameserver 188.8.131.52). [network] hostname = JTI-ITL05-DEBIAN
The hostname does change successfully. However, even when the mountFsTab key is set to true, the fstab file’s mounts are not being applied when the Debian WSL2 instance starts. To test the fstab file, I first tried running the following command.
Sudo mount -a
The command successfully mounts the two entries I have in
/etc/fstab. Here is an example of my fstab entries to illustrate the structure using the DrvFs file system plugin Microsoft created for WSL.
#file system dir type options dump pass \\\\domain.com\\share\\path /mnt/mountdir drvfs defaults,uid=1000,gid=1000 0 0 C: /mnt/c drvfs defaults,uid=1000,gid=1000 0 0
To test the processing of fstab, I included a line to mount a local device, drive C in Windows. The line that mounts a local device, mounts successfully when the WSL2 instance starts up. The other line pointing to a Windows network share does not mount on startup, but I can mount it after the instance boots to a terminal CLI. I can confirm the results using the wsl command to shutdown the instance and start it back up. The fstab file is being processed on start up.
I don’t see a relevant log file in
/var/log to check for errors. All of my tests have failed so far to get the fstab file to mount a Windows network share when WSL2 Debian starts up.
How do I get the WSL2 instance to automatically mount a Windows network share found in the fstab file?