Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure mount dir and windows drive letter #38

Closed
philippe-granet opened this issue Oct 3, 2021 · 2 comments · Fixed by #40
Closed

Configure mount dir and windows drive letter #38

philippe-granet opened this issue Oct 3, 2021 · 2 comments · Fixed by #40

Comments

@philippe-granet
Copy link

philippe-granet commented Oct 3, 2021

First, thanks for your great work, last release with separate distro and iptables is awesome 🎉 !

At work, some PC have Windows system in an other drive than C:, exemple D:.
You can also configure directory where drives are mounted, in /etc/wsl.conf, see https://docs.microsoft.com/en-us/windows/wsl/wsl-config:

Section: [automount]
root (default: /mnt/): Sets the directory where fixed drives will be automatically mounted.
For example, if you have a directory in WSL at /windir/ and you specify that as the root, you would expect to see your fixed drives mounted at /windir/c

I think you use these code to find real values:
https://github.com/wslutilities/wslu/blob/173da54ec9b138c1c5d13dd24398ed1d114024f8/src/wslu-header#L111-L146

function interop_prefix {

	win_location="/mnt/"
	if [ -f /etc/wsl.conf ]; then
		tmp="$(awk -F '=' '/root/ {print $2}' /etc/wsl.conf | awk '{$1=$1;print}')"
		[ "$tmp" == "" ] || win_location="$tmp"
		[[ "$win_location" =~ ^.*/$ ]] || win_location="$win_location/" # make sure it always end with slash
		unset tmp
	fi
	echo "$win_location"

	unset win_location
}

function sysdrive_prefix {
	win_location="$(interop_prefix)"
	hard_reset=0
	for pt in $(ls "$win_location"); do
		if [ $(echo "$pt" | wc -l) -eq 1 ]; then
			if [ -d "$win_location$pt/Windows/System32" ]; then
				hard_reset=1
				win_location="$pt"
				break
			fi
		fi 
	done

	if [ $hard_reset -eq 0 ]; then
		win_location="c"
	fi

	echo "$win_location"

	unset win_location
	unset hard_reset
}
@sakai135
Copy link
Owner

sakai135 commented Oct 4, 2021

@philippe-granet Can you try it with the changes in #40? You can get the updated distro from the build artifact here.

@philippe-granet
Copy link
Author

@sakai135 I have tested with this build artifact and all is OK for me, it works as expected.
Thanks! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants