Use this script to mount drives in WSL. Example: ezmount.sh f to mount the F: drive.
Thanks to https://askubuntu.com/a/1422805/778411 for specifying how to make the WSL user the default owner of files.
Use this script to mount drives in WSL. Example: ezmount.sh f to mount the F: drive.
Thanks to https://askubuntu.com/a/1422805/778411 for specifying how to make the WSL user the default owner of files.
| #!/usr/bin/env bash | |
| DRIVE_LETTER="$1" | |
| if [[ ! "$DRIVE_LETTER" ]]; then | |
| echo Please enter a drive letter. | |
| exit 1 | |
| fi | |
| mount_path="/mnt/${DRIVE_LETTER,,}" | |
| if [[ ! -d "$mount_path" ]]; then | |
| sudo mkdir "$mount_path" | |
| if [[ "$?" ]]; then | |
| echo Something went wrong in trying to create the directory "$mount_path". | |
| exit 1 | |
| fi | |
| fi | |
| sudo mount -t drvfs "${DRIVE_LETTER^^}:" "$mount_path" -o "uid=$(id -u $USER),gid=$(id -g $USER),metadata" |