Welp. That was a waste of time: https://docs.microsoft.com/en-us/windows/wsl/wsl-config#automount
This commit is contained in:
parent
bea102ce50
commit
6e4eecd613
|
@ -1,41 +0,0 @@
|
||||||
# Mount winshare within wsl on win vm
|
|
||||||
#
|
|
||||||
# Necessary to mount any device that doesn't get mounted automatically by wsl
|
|
||||||
#
|
|
||||||
# Ref: https://docs.microsoft.com/en-us/archive/blogs/wsl/file-system-improvements-to-the-windows-subsystem-for-linux
|
|
||||||
|
|
||||||
mountwinshare() {
|
|
||||||
local targetdir="/mnt/z"
|
|
||||||
local sharedir="Z:"
|
|
||||||
|
|
||||||
if [ "$1" == "-v" ]; then
|
|
||||||
local verbose=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only do this in a specific env
|
|
||||||
if [ "$(hostname)" == "DT-KD-VM" ]; then
|
|
||||||
# Create the mountpoint if it doesn't exist
|
|
||||||
if [ ! -d "$targetdir" ]; then
|
|
||||||
if sudo mkdir "$targetdir"; then
|
|
||||||
[ -n "$verbose" ] && echo "mountwinshare: Created mount directory: $targetdir"
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "mountwinshare: Failed to create mount directory: $targetdir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
# Check if $targetdir is already in use as a mountpoint
|
|
||||||
if mountpoint -q "$targetdir"; then
|
|
||||||
[ -n "$verbose" ] && echo "mountwinshare: $targetdir already in use. Skipping."
|
|
||||||
else
|
|
||||||
# Do the thing! (see reference for details)
|
|
||||||
if sudo mount -t drvfs "$sharedir" "$targetdir"; then
|
|
||||||
[ -n "$verbose" ] && echo "mountwinshare: Mounted $sharedir to $targetdir"
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "mountwinshare: Failed to mount $sharedir to $targetdir"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
[ -n "$verbose" ] && echo "mountwinshare: wrong env. skipping"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
mountwinshare
|
|
Loading…
Reference in New Issue