This article covers how to mount a linux disk in windows. A typical external usb disk drive that’s been formatted for linux (for example ext4). With WSL you can still use this disk and pass files to it via the windows explorer.
Pre-requisites
You’ll need to have WSL installed and running on your windows machine. This basically allows you to run linux within the Windows environment. I might add a post on how to do that, but not today…
Mounting the external disk to Linux on Windows
You might be familiar with how to mount a disk drive in linux. Getting it set up to mount a linux disk Windows takes a few extra steps. When you plug in your hard drive, Windows won’t be able to read it initially. So open a powershell terminal and enter the following command:
Get-CimInstance Win32_DiskDrive
You should see something like the following list, showing a bunch of details:
\\.\PHYSICALDRIVE0 …
\\.\PHYSICALDRIVE1 …
This command returns all the connected drives, regardless of whether it can read the contents or not. DRIVE0 is likely your C drive. Any other disks will be external drives etc. Look for the one that looks like the HDD drive you want to mount, based on the provided details. You want WSL (linux) to recognise this disk, so enter the following command next, where the drive number in my case was 1:
wsl --mount \\.\PHYSICALDRIVE1
This will mount the disk, so running regular command will recognise it as an external disk.
Important: run powershell with administrator access, or else it will complain about permissions and won’t be able to mount.
Mounting the Linux disk with WSL
Now you can use a regular terminal. Type wsl as the command and you’ll see the terminal prompt, something like the following:
user@computer:/mnt/c/Users/username$
Now you can run linux commands. If you run the lsblk command you will see the connected drives, partitions etc. Something like this:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 356.9M 1 disk
sdb 8:16 0 159.4M 1 disk
sdc 8:32 0 1G 0 disk [SWAP]
sdd 8:48 0 1.8T 0 disk
├─sdd1 8:49 0 931.3G 0 part
└─sdd2 8:50 0 931.7G 0 part
sde 8:64 0 1T 0 disk /mnt/wslg/distro
In my case my external disk has two partitions, seen under sdd. Let’s connect to sdd1 (yours will likely be different). As is normal for linux, you’ll need to create a folder for mounting first.
Important note: WSL is not configurable in terms of Linux kernels etc, like any other regular distro. You get what you get and that’s that. This means that your disk might not be supported. I had an issue where I was unable to mount an old XFS drive because it was using an incompatible v4 version of the filesystem, which is not compatible with WSL.
Create a mount folder and mount it:
sudo mkdir /mnt/usb
sudo mount /dev/sdd1 /mnt/usb
Run the lsblk command again and you should see the disk is mounted to this new folder.
File Permissions
Unless you’ve already set up your disk to allow any user to add files etc, you won’t have permission in Windows explorer to manage the files on the HDD. If you’ve not done this already, you’ll need to set up the following permissions. Use these if you want these files freely accessible across machines, like a regular external HDD:
sudo chmod -R a+rwX /mnt/usb
Accessing the disk via Windows explorer
Now the fun part, you will be able to open the drive in a regular old windows explorer window and manage files. Enter the following in your explorer address bar:
\\wsl$\ubuntu\mnt\usb
I chose ubuntu as my WSL distro when I installed it. Your might be different, so change accordingly.
You should now be able to move files to and from this drive!
Copying files between Windows and Linux
When moving files between Windows and Linux, you might get some pop ups regarding the data. One I got was something along the lines of:
“Are you sure you want to copy this file without its properties?”
This means Windows can’t store some Windows-specific metadata on the destination filesystem (your ext4 USB drive).
The file’s contents are copied correctly. What may be lost includes things like:
- NTFS Alternate Data Streams (ADS)
- Windows security information (ACLs)
- “Downloaded from the Internet” (
Zone.Identifier) marker - Some Windows file attributes and metadata
For normal files (videos, photos, documents, ROMs, ISOs, source code, etc.), this is usually nothing to worry about. The actual file data is unchanged.
This warning is expected because ext4 doesn’t support all of NTFS’s metadata. So you can just click yes and ignore it.
One caveat with using Windows explorer with WSL to transfer files is that you can find it to be a bit flaky. Sometimes the transfer rate will drop, even stop, and then continue. If you’re a comfortable Linux user you might find it better to transfer files via terminal instead. When you want to mount a linux disk in windows, you should assume you might need to get the terminal involved somewhere!
Safely unmounting the external HDD
Once you’re done you’ll need to safely remove the drive. Run the following command via the terminal running Linux:
sudo umount /mnt/usb
Then in powershell you’ll need to run the following, where the number is your drive:
wsl --unmount \\.\PHYSICALDRIVE1
Once umount succeeds:
- If Windows still sees the USB device, use the Safely Remove Hardware icon in the Windows system tray and eject it.
- If Windows doesn’t recognise the filesystem (common for ext4), once WSL has successfully unmounted it, it’s generally safe to unplug the drive.