Introduction
In this article, we will discuss how to mount a Windows folder in the WSL (Windows Subsystem for Linux) environment using fstab (File System Table) in Debian. This process allows you to access your Windows files directly from the Linux terminal, which can be particularly useful for developers.
Prerequisites
- A Debian-based WSL distribution installed on your system.
- A Windows folder that you want to mount.
- Sudo privileges.
Mounting Windows Folder Manually (sudo mount)
Before we mount the Windows folder using fstab, let's first check if it is possible to mount it manually using the sudo mount command.
sudo mount -t drvfs
Replace
with the desired mount point in your Linux filesystem.
Adding to fstab
To mount the Windows folder automatically at startup, we need to add an entry to the fstab file.
Getting Start-up Message
Before we add the entry to the fstab file, let's first check the getstart-up message to ensure that the Windows filesystem is mounted automatically at startup.
cat /etc/fstab
Look for an entry similar to the following:
# /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the UUIDs of your logical volumes.
# You can use UUID=xxxxxxxx-xx:xx:xx:xx:xx:xx in the fstab file
# instead of /dev/sdxxp1
#
# / was on /dev/sda1 during installation
# /boot was on /dev/sda2 during installation
# /boot/efi was on /dev/sda3 during installation
# /home was on /dev/sda5 during installation
# swap was on /dev/sda6 during installation
# /swapfile is automatically created on /etc/init.d/rc.local
# /dev/sda1 / ext4 defaults 0 0
# /dev/sda5 /home ext4 defaults 0 0
# swap was on /dev/sda6, but is now a swapfile.
# /dev/sda6 none swap sw 0 0
If you don't see an entry for your Windows folder, add one now.
Editing fstab
Open the fstab file for editing using your preferred text editor:
sudo nano /etc/fstab
Add the following entry:
# /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the UUIDs of your logical volumes.
# You can use UUID=xxxxxxxx-xx:xx:xx:xx:xx:xx in the fstab file
# instead of /dev/sdxxp1
#
# / was on /dev/sda1 during installation
# /boot was on /dev/sda2 during installation
# /boot/efi was on /dev/sda3 during installation
# /home was on /dev/sda5 during installation
# swap was on /dev/sda6 during installation
# /swapfile is automatically created on /etc/init.d/rc.local
# /dev/sda1 / ext4 defaults 0 0
# /dev/sda5 /home ext4 defaults 0 0
# swap was on /dev/sda6, but is now a swapfile.
# /dev/sda6 none swap sw 0 0
# Add your Windows folder entry here
#
# Example entry for Windows folder
# C:\Users\username\Desktop /mnt/c/Users/username/Desktop drvfs defaults 0 0
Replace
with the desired mount point in your Linux filesystem.
Testing the Mount
Save and close the fstab file. Now, let's test the mount:
sudo mount -a
If the mount is successful, you should see a message similar to the following:
mount: /mnt/c/Users/username/Desktop is already mounted or not a valid target
mount: /mnt/c/Users/username/Desktop: mounted other on different device
This message indicates that the mount was successful.
Summary
In this article, we discussed how to mount a Windows folder in the WSL environment using fstab in Debian. We first checked if the folder could be mounted manually using the sudo mount command. We then added an entry to the fstab file and tested the mount. With these steps, you can access your Windows files directly from the Linux terminal at startup.