0

I have a shared partition setup as ntfs for storing Linux files between distros and WSL. My /etc/fstab for the shared partition looks like this:

UUID=F2C2ACE4C2ACADF3 /mnt/e    ntfs-3g permissions,locale=en_US.utf8,x-gvfs-show 0     0

I get this error when trying to turn of executable bit:

$ ll /mnt/e/var/lib/vnstat
total 20
drwxrwxrwx 1 root root 4096 May 20 11:56 ./
drwxr-xr-x 1 root root    0 May 20 09:39 ../
-rwxrwxrwx 1 root root 2792 May 20 15:58 enp59s0*
-rwxrwxrwx 1 root root 2792 May 20 15:58 .enp59s0*
-rwxrwxrwx 1 root root 2792 May 20 15:58 wlp60s0*
-rwxrwxrwx 1 root root 2792 May 20 15:58 .wlp60s0*

$ sudo chmod a-x /mnt/e/var/lib/vnstat

$ ll /mnt/e/var/lib/vnstat
ls: cannot access '/mnt/e/var/lib/vnstat/.': Permission denied
ls: cannot access '/mnt/e/var/lib/vnstat/..': Permission denied
ls: cannot access '/mnt/e/var/lib/vnstat/.enp59s0': Permission denied
ls: cannot access '/mnt/e/var/lib/vnstat/.wlp60s0': Permission denied
ls: cannot access '/mnt/e/var/lib/vnstat/enp59s0': Permission denied
ls: cannot access '/mnt/e/var/lib/vnstat/wlp60s0': Permission denied
total 0
d????????? ? ? ? ?            ? ./
d????????? ? ? ? ?            ? ../
-????????? ? ? ? ?            ? enp59s0
-????????? ? ? ? ?            ? .enp59s0
-????????? ? ? ? ?            ? wlp60s0
-????????? ? ? ? ?            ? .wlp60s0

I'm able to rebuild the shared files using:

$ sudo rm -rf /mnt/e/var/lib/vnstat

$ sudo cp -rp /var/lib/vnstat /mnt/e/var/lib

$ sudo chmod a+r /mnt/e/var/lib/vnstat/*

$ ll /mnt/e/var/lib/vnstat
total 16
drwxr-xr-x 1 vnstat vnstat    0 Oct 31  2017 ./
drwxr-xr-x 1 root   root      0 May 20 16:09 ../
-rw-r--r-- 1 vnstat vnstat 2792 May 20 16:14 enp59s0
-rw-r--r-- 1 vnstat vnstat 2792 May 20 16:14 .enp59s0
-rw-r--r-- 1 vnstat vnstat 2792 May 20 16:14 wlp60s0
-rw-r--r-- 1 vnstat vnstat 2792 May 20 16:14 .wlp60s0

I'm still curious to know how the files get corrupted as shown in the first section?

I'm also appearing to having ownership problems when /etc/fstab is parsed and ownership defaults to either root or my user ID depending on settings.

  • Listing should be OK, but no wildcards (no searching), so if you list a name, it should be found. – ubfan1 May 20 '18 at 22:19
  • @steeldriver I think you are right. I had left the /* off the end of .../vnstat. Still I'm surprised at the apparent corruption. I guess it could have been reversed by turning X bit back on? If you'd like to post an answer I'd be happy to accept. – WinEunuuchs2Unix May 20 '18 at 22:19
4

The execute bit on directories must be set to allow users to stat its contents. Without that bit, you get the output you describe. There is no corruption of the files at all, you just revoked your permissions to examine them.

Simply restore the execute bit on the directory to fix your situation, in your case using

sudo chmod a+x /mnt/e/var/lib/vnstat

Here's an example terminal log illustrating the behaviour:

$ ll folder/
total 0
drwxrwxr-x  3 bytecommander bytecommander 100 Mai 21 00:19 ./
drwxrwxrwt 19 root          root          460 Mai 21 00:21 ../
-rw-rw-r--  1 bytecommander bytecommander   0 Mai 21 00:19 bar
-rw-rw-r--  1 bytecommander bytecommander   0 Mai 21 00:19 foo
drwxrwxr-x  2 bytecommander bytecommander  40 Mai 21 00:19 meh/

$ chmod a-x folder/

$ ll folder/
ls: cannot access 'folder/.': Permission denied
ls: cannot access 'folder/..': Permission denied
ls: cannot access 'folder/meh': Permission denied
ls: cannot access 'folder/bar': Permission denied
ls: cannot access 'folder/foo': Permission denied
total 0
d????????? ? ? ? ?            ? ./
d????????? ? ? ? ?            ? ../
-????????? ? ? ? ?            ? bar
-????????? ? ? ? ?            ? foo
d????????? ? ? ? ?            ? meh/

$ chmod a+x folder/

$ ll folder/
total 0
drwxrwxr-x  3 bytecommander bytecommander 100 Mai 21 00:19 ./
drwxrwxrwt 19 root          root          460 Mai 21 00:21 ../
-rw-rw-r--  1 bytecommander bytecommander   0 Mai 21 00:19 bar
-rw-rw-r--  1 bytecommander bytecommander   0 Mai 21 00:19 foo
drwxrwxr-x  2 bytecommander bytecommander  40 Mai 21 00:19 meh/
  • 1
    Thank you. I had promised to accept Steel's answer. If he doesn't post one I'll accept this later :) – WinEunuuchs2Unix May 20 '18 at 22:26
  • @WinEunuuchs2Unix it's all good - please feel free to accept this answer – steeldriver May 20 '18 at 22:50
  • @steeldriver Thank you. You're both extremely intelligent hardworking professionals IMO anyway. – WinEunuuchs2Unix May 20 '18 at 23:42

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.