Mounting an ext4 Drive in Windows Subsystem for Linux (WSL)
Introduction
Windows Subsystem for Linux (WSL) has become a popular way for Windows users to run a Linux environment alongside their Windows system. However, one challenge many face is mounting ext4 drives within WSL. This guide will walk you through the steps to mount an ext4 drive on WSL easily.
Prerequisites:
- A Windows machine with WSL installed (WSL 2 recommended)
- Administrative access to PowerShell
Step I: Identify the Drive to Mount
- Open PowerShell as an administrator.
- Run the following command to list all the available drives and find the one you want to mount:
GET-CimInstance -query "SELECT * from Win32_DiskDrive"
Note down the drive information, such as \.\PHYSICALDRIVE2
.
Step II: Mount the Drive in WSL
- In your PowerShell window, execute the following command to mount the identified drive in WSL, replacing
.\PHYSICALDRIVE2
with the drive you want to mount:
wsl.exe --mount \.\PHYSICALDRIVE2 --bare
Step III: Verify the Drive Mounting
- Open another terminal and access your WSL environment. To check if the drive is successfully mounted, run the following command:
lsblk
You should see the drive listed, typically as “/dev/sdb”.
Step IV: Mount the ext4 Drive
- Finally, mount the ext4 drive to a directory in your WSL environment using the following command, replacing
/dev/sdb
with the correct drive path and/mnt/mydrive
with your desired mount point:
sudo mount /dev/sdc /mnt/mydrive
Voilà! You can now read and write to the ext4 drive from within your WSL environment.
Conclusion:
Mounting an ext4 drive in Windows Subsystem for Linux (WSL) is straightforward, enabling efficient access and operations across both Linux and Windows environments.