3
1
I recently installed WSL on my Win 10 (Version 10.0.17134.228) and I'm trying to access my files on a disk mounted on windows from linux.
In my PC I have 2 HD:
- First Disk: A single partition where windows is installed (C:/ in Windows)
- Second Disk: It has 2 partitions
- A partition which contains Ubuntu (for dual boot)
- An NTFS partition which just contains data (D:/ in Windows)
When I work from windows or Ubuntu (the dual boot one) I access the data from the D:/ partition.
Now I wanted to access the data in the D:/ partition from WSL, but it tells me I don't have permissions
When I ls in the directory I see
mypc@DESKTOP-1CEE3H9:/$ ls -la /mnt/d/mypath/child/
total 36
drwxrwxrwx 1 myuser myuser 4096 Jun 2 19:54 .
drwxrwxrwx 1 myuser myuser 4096 Aug 18 00:52 ..
---------- 1 myuser myuser 1884 Dec 27 2017 myfile1
d--x--x--x 1 myuser myuser 4096 Jun 24 23:29 myfolder1
And in the parent path I see
mypc@DESKTOP-1CEE3H9:/$ ls -la /mnt/d/mypath/
total 180
drwxrwxrwx 1 myuser myuser 4096 May 21 2017 .
drwxrwxrwx 1 myuser myuser 4096 Aug 24 22:59 ..
drwxrwxrwx 1 myuser myuser 4096 Aug 13 2015 myfolder2
d--x--x--x 1 myuser myuser 4096 Sep 24 2015 myfolder3
-rwxrwxrwx 1 myuser myuser 268 Jan 19 2015 myfile2
In contrast, in the C:/ partition I see
mypc@DESKTOP-1CEE3H9:/$ ls -la /mnt/c/Users/MyUser/Desktop/
total 505276
drwxrwxrwx 1 myuser myuser 512 Aug 20 23:12 .
drwxrwxrwx 1 myuser myuser 512 Aug 18 01:07 ..
-rwxrwxrwx 1 myuser myuser 1604 Jun 17 15:47 myfile3
drwxrwxrwx 1 myuser myuser 512 Mar 31 13:16 myfolder4
On windows I can access all of those files.
In WSL I can access myfolder2, myfolder4 and I can read myfile2, myfile3.
I can not access myfile1, myfolder1, myfolder3.
My partitions are
C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000)
D: on /mnt/d type drvfs (rw,noatime,uid=1000,gid=1000)
I don't understand why the permissions on the files are different on the disk. Might it be because I create/edit some of them from Ubuntu (dual boot) and some from Windows?
How can I fix the problem so that I can access the files?
I did not try chmod the disk because it is big, I don't want to risk breaking any file and it sounds to me like that would fix the symptoms and not the root cause of the permission problems.
Thanks
Edit
Following Biswapriyo comment I looked better into two files which I can and cannot access.
I checked the file Properties, and under the Detail tab I saw that the owner of the 2 files is different:
- The file I can access has owner
DESKTOP-1CEE3H9\MyUser - The file I cannot access has owner
Administrators
I also checked another file I can access, and this one has as owner a long sequence of numbers and letters.
I tried changing the owner of one file from Administrators to DESKTOP-1CEE3H9\MyUser and it looks like I now see the right permissions in WSL.
Could this be related?
1+1 for this well formatted and detailed question. If any Windows program create/edit file/folder the permission will set to
000. Just simply change it withchmod. Or you can do that withNtSetEaFile()withCreateFile(). – Biswapriyo – 2018-08-25T12:47:13.100Thanks! Is this true even if these files where created before I ever enabled WSL? Why can I access and edit these files from the Ubuntu (dual boot)? Is this some specifics of drvfs? – Makers_F – 2018-08-25T14:15:42.380
Because in WSL file permission is accessed as NTFS Extended Attributes (EA). The driver behind WSL mimics EA as Linux file permission. But normally distributions (dual boot) fetch file permission as usual. – Biswapriyo – 2018-08-25T16:39:37.407
But on windows I can edit the file, so I would expect that to be reflected inside WSL by allowing me to read/write the file. (I'm not familiar with how permissions are stored on the FS in both linux and Win, that might be why I'm not understanding): I ended up solving the problem by assigning ownership to my user in Windows, and now I can access the files in WSL as well. Thanks for the help! – Makers_F – 2018-08-25T16:43:59.107