0

Recently starting a new environment in WSL2. I am able to create environments in the WSL2 file system, but when I switch to a mounted drive it fails.

addohm@addohm-lap:~$ cd ~
addohm@addohm-lap:~$ python3 -m venv env
addohm@addohm-lap:~$ ls
env  onedrive
addohm@addohm-lap:~$ cd onedrive
addohm@addohm-lap:~/onedrive$ cd _code_projects/python_projects/nwfb/
addohm@addohm-lap:~/onedrive/_code_projects/python_projects/nwfb$ python3 -m venv env
Error: Command '['/mnt/d/OneDrive/_code_projects/python_projects/nwfb/env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
addohm@addohm-lap:~/onedrive/_code_projects/python_projects/nwfb$ ls
README.md  env     main.py                   multi.py          templates  test2.py
assets     gui.py  multi-DESKTOP-18V5EK2.py  requirements.txt  test.py
addohm@addohm-lap:~/onedrive/_code_projects/python_projects/nwfb$ source env/bin/activate
-bash: env/bin/activate: No such file or directory
addohm@addohm-lap:~/onedrive/_code_projects/python_projects/nwfb$

It seems the contents of the mounted drives are all owned by root:root.

drwxrwxrwx 1 root root 4096 Nov 26 12:16  nwfb

Since I am not exactly familiar with the interactions between WSL2 and the windows file system, is it safe to modify all the ownership of my onedrive folder contents? Will I have to repeatedly change ownership for new files added to the drive?

Edit: Small test, left side is ownership modified, right side is not. Changing ownership seems insignificant. Since /mnt/ contains all mounted drives on the system, I wonder if I should change ownership of the entire drive chown -R addohm:addohm /mnt/d enter image description here

Edit 2: after changing ownership of files on external drives, the ownership doesn't actually change.

addohm@addohm-lap:~/onedrive/_code_projects/python_projects/nwfb$ sudo chown -R addohm:addohm main.py
addohm@addohm-lap:~/onedrive/_code_projects/python_projects/nwfb$ ls -al
-rwxrwxrwx 1 root root 7169 Nov 21 09:58 main.py
addohm
  • 2,248
  • 3
  • 14
  • 40

1 Answers1

0

I found my answer in this SO post: wsl2 fail to change file permissions

I essentially turn on the metadata options and added myself as the owner:group for the mount ownership. I got the appropriate ID's by using the user -u <user name> and user -g <group name> commands.

# Enable extra metadata options by default
[automount]
enabled = true
root = /mnt/
options = "metadata,uid=1000,gid=1000,umask=22,fmask=11"
mountFsTab = false
addohm
  • 2,248
  • 3
  • 14
  • 40