If I am a user of the Windows Subsystem for Linux (WSL), I might have noticed that when I plug in a USB flash drive, it doesn’t automatically appear in my Linux environment. Unlike my C: drive, which is typically mounted at /mnt/c, WSL does not automatically mount removable drives.
Fortunately, accessing my USB drive from within WSL is a straightforward process. This guide will walk through the two primary methods I use for mounting a USB drive in WSL2, from a simple drive letter mount to accessing the raw physical disk.
Understanding the Challenge: Why USB Drives Don’t Auto-Mount
WSL is designed to be a lightweight and isolated environment. For security and stability reasons, it does not automatically mount every device that is connected to my Windows host. This means I have to manually tell WSL to mount the drive.
Prerequisite: WSL2 is Recommended
The methods described below work best with WSL2, which has a full Linux kernel and better support for hardware access. If I am still on WSL1, I should consider upgrading (wsl --set-version <DistroName> 2).
Method 1: The Easy Way (Mounting a Windows Drive Letter)
This is the simplest and most common method for accessing the files on a USB drive. It works by mounting the drive letter that Windows has assigned to the USB (e.g., E:).
Step 1: Identify the USB Drive Letter in Windows
First, I plugged in my USB drive and noted the drive letter that Windows assigned to it in File Explorer (e.g., E:).
Step 2: Mount the Drive in WSL
- I opened my WSL terminal (e.g., Ubuntu).
- Create a mount point. This is simply a directory where the contents of the USB will be accessible.
sudo mkdir /mnt/e - Use the
mountcommand to attach the Windows drive to the mount point.sudo mount -t drvfs E: /mnt/e
Command Explanation:
sudo mount: The standard Linux command to mount a filesystem.-t drvfs: Specifies the filesystem type asdrvfs(Drive File System), which is the protocol WSL uses to communicate with the Windows filesystem.E:: The Windows drive letter I want to mount./mnt/e: The destination directory (mount point) inside WSL.
Step 3: Access My Files
I can now access the files on my USB drive by navigating to the mount point.
ls /mnt/e
cd /mnt/eMethod 2: The Advanced Way (Mounting a Raw Physical Disk)
For more advanced use cases, such as using Linux tools like dd, fdisk, or gparted, I may need to access the raw physical disk instead of just the formatted volume. The wsl --mount command allows me to do this.
Step 1: Identify the USB Disk in Windows
I opened PowerShell as an Administrator and listed all physical disks to find the disk number of my USB drive.
Get-DiskExample Output:
Number Friendly Name OperationalStatus Total Size Partition Style
------ ------------- ----------------- ---------- ---------------
0 NVMe SSD Online 512 GB GPT
1 USB DISK 3.0 Online 16 GB MBRDisk 1, which corresponds to the path \.\PHYSICALDRIVE1.
Step 2: Mount the Physical Disk into WSL
In the same administrative PowerShell terminal, use the wsl --mount command to attach the physical disk to WSL.
wsl --mount \\.\PHYSICALDRIVE1 --bare
The --bare flag attaches the physical disk without attempting to mount its filesystems.
Step 3: Identify and Mount the Partition in WSL
- Now, switch to your WSL terminal and list the block devices.
I should now see a new device, such as
lsblk/dev/sdb, with its partitions (e.g.,/dev/sdb1). - Create a mount point and mount the partition.
sudo mkdir /mnt/usb sudo mount /dev/sdb1 /mnt/usb
I can now access the files at /mnt/usb and use tools like fdisk /dev/sdb to interact with the raw disk.
How to Safely Unmount a USB Drive
Before I physically unplug my USB drive, I must unmount it to prevent data corruption.
For Method 1 (Drive Letter Mount):
sudo umount /mnt/eFor Method 2 (Physical Disk Mount):
- Unmount the partition inside WSL:
sudo umount /mnt/usb - Detach the physical disk from WSL in your PowerShell terminal:
wsl --unmount \\.\PHYSICALDRIVE1
Troubleshooting Common Issues
| Issue | Cause | Fix |
|---|---|---|
USB not showing in /mnt/ |
It’s not mounted yet. | Use sudo mount -t drvfs E: /mnt/e. |
wsl --mount gives an error |
I am not running PowerShell as an Administrator. | Close and reopen PowerShell as an Administrator. |
| Cannot write to the USB | The filesystem was mounted as read-only. | For drvfs, I can try adding the -o metadata option to the mount command to better handle permissions. |
| WSL1 doesn’t show disks | This is a limitation of WSL1. | Upgrade my distribution to WSL2 with wsl --set-version <DistroName> 2. |
Further Reading
If you’re encountering other issues with WSL, such as startup crashes, check out our troubleshooting guide:
Conclusion
Accessing USB drives in WSL2 is a simple process once I know the correct commands.
- For quick and easy file access, mounting the Windows drive letter is the best approach.
- For advanced tasks that require raw disk access, the
wsl --mountcommand provides the power I need.
By following these steps, I can seamlessly integrate my USB storage into my WSL workflow, giving myself the best of both the Windows and Linux worlds.