How can I access my system's USB drive in Windows Subsystem for Linux (WSL)? I'm using an Ubuntu distribution.
3 Answers
It's quite simple:
Create the mount point:
mkdir /mnt/g
(add whatever word or letter you want, I used the matching letter to the windows drive. You might need to usesudo
to create the directory in the/mnt
directory.)Mount the drive to the directory using
sudo mount -t drvfs G: /mnt/g
Consider a slight alternative on the currently accepted answer:
sudo mkdir /mnt/<usb_drive_letter>
sudo mount -t drvfs <usb_drive_letter>: /mnt/<usb_drive_Letter> -o uid=$(id -u $USER),gid=$(id -g $USER),metadata
For a USB drive which is assigned in Windows to H:
, for example:
sudo mkdir /mnt/h
sudo mount -t drvfs h: /mnt/h -o uid=$(id -u $USER),gid=$(id -g $USER),metadata
In general, the accepted answer will work, but note that drives that are manually mounted this way do not follow the normal WSL automount settings.
Most fixed Windows drives will be mounted:
- In
/mnt/<drive_letter
for each drive. - With the default WSL user and its primary group as the owner of the mount.
- A default umask/fmask/dmask of 000
- The
metadata
disabled for performance, which means only a "simplified permission" model will be used to map Windows/NTFS and Linux permissions.
However, USB drives that are manually mounted do not follow the [automount]
settings.
At the very least, you'll probably want your WSL user to be the owner, which is done with the -o uid=$(id -u $USER),gid=$(id -g $USER)
(usually, this is the same as -o uid=1000,gid=1000` in a default Ubuntu/WSL installation).
Adding in the metadata
option can be useful if you want to preserve permissions via rsync
or cp -a
.

- 17,888
-
3The owner options listed here are skipped on almost every other description I found. Although they weren't needed in a lot of instances they were needed in order for me to rsync data to my external drive without a load of errors. – Phil Rosenberg Oct 24 '22 at 16:01
The answer from NotTheDr01ds was very useful, although I did not find this to be the full answer.
Anyone feel free to edit the following with additional clarity and extra information, the following is a sequential list of tasks before I could copy to a WSL Distro with an attached storage device for running a backup.
Windows 10 host: ensure SSH Service is active
PowerShell (as Admin)...
Start-Service sshd
Note the real Windows 10 username (only require after the forward-slash)
Source Linux/macOS host: test connectivity / login with the Windows 10 Local Account password
Remote Shell...
ssh Username@192.168.0.10
Windows 10 host: If requiring update/reset to local account password
PowerShell or Command Prompt...
# Use following in Command Prompt / PowerShell. Be aware this will require reboot and login with this password before Windows 10 PIN etc. will work again
net user Username PASSWORD_HERE
NOTE: rsync incompatibilities
The rsync binary may be too low on different Ubuntu distros which may cause unexpected errors from recent rsync development incompatibilities
NOTE: rsync unsupported features with Windows WSL
- use of '--crtimes' will result in errors such as.... rsync: The server does not support --crtimes (-N)
- use of '--fileflags' will result in errors such as.... rsync: on remote machine: --fileflags: unknown option
- use of '--xattrs' will result in errors such as.... rsync: [receiver] rsync_xal_set: lsetxattr("/mnt/h/path/.filename.txt.AB1de","user.com.apple.macl") failed: Operation not supported (95)
In addition, Windows WSL rsync is temperamental and may require the drive mounted with -o metadata to permit....
- use of --perms
- use of --times
Windows 10 host: If rsync incompatibility
May have to consider using OpenSUSE Tumbleweed for rsync 3.2.7+ package (at time of writing, not available with Ubuntu distros).
PowerShell...
wsl --install --distribution openSUSE-Tumbleweed
WSL Distro Shell...
# Example
zypper install rsync
Windows 10 WSL Distro: Mount the desired drive
To mount a drive to the WSL OS (e.g. an external disk drive), run the following from Admin user (e.g. user 1000); do NOT run this from root (e.g. user 0)
On reboot of Windows, this will likely reset the mount options to noatime.
WSL Distro Shell...
sudo mkdir /mnt/h
sudo mount -t drvfs H:\\ /mnt/h -o rw,relatime,dirsync,metadata,uid=$(id -u $USER),gid=$(id -g $USER)
exit
Then, to enable rsync to begin working the WSL Distro must be rebooted. Shutdown the WSL instance and start the instance again
PowerShell...
wsl --shutdown
wsl -d openSUSE-Tumbleweed
From the source Linux/macOS host: dry run test
Establish the sync works (use the Windows 10 Local Account password).
Remote shell...
/usr/local/bin/rsync \
--dry-run \
--rsync-path='wsl rsync' \
--recursive --perms --times --human-readable --itemize-changes --copy-links --progress \
--exclude '.DS_Store' \
/path/test \
Username@192.168.0.10:/mnt/h/test
From the source Linux/macOS host, real test
Establish the sync works to transfer the directories and files (use the Windows 10 Local Account password).
Remote shell...
/usr/local/bin/rsync \
--rsync-path='wsl rsync' \
--recursive --perms --times --human-readable --itemize-changes --copy-links --progress \
--exclude '.DS_Store' \
/path/test \
Username@192.168.0.10:/mnt/h/test
From the source Linux/macOS host, perform checksum double check
After sync works (use the Windows 10 Local Account password), establish all files were copied across correctly with checksum.
Remote shell...
/usr/local/bin/rsync \
--checksum \
--checksum-choice=md5 \
--rsync-path='wsl rsync' \
--recursive --perms --times --human-readable --itemize-changes --copy-links --progress \
--exclude '.DS_Store' \
/path/test \
Username@192.168.0.10:/mnt/h/test

- 1
-
Welcome to Ask Ubuntu! I'm thinking you probably meant to post this on a different question? This one doesn't have anything to do with
rsync
orssh
;-) – NotTheDr01ds Nov 27 '22 at 21:18