0

I have a problem with accessing files on an ext4 file system mounted as type NFS on a Linux server running CENTOS 6.5. I know the files exist on this file system because I can see them when I explicitly call them (e.g. with ls, awk, or cat), but are not visible to some programs like rsync or when piped from ls into another program like grep or awk.

As an example to clarify, the following will return empty:

ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/ | grep WCI\.BH1\.IU.10

While this shows me that the file actually exists:

ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/WCI.BH1.IU.10.

In the numerous directories where this is a problem, most files appear normally, without needing to be called explicitly as shown in the example.

Can anyone help me understand this problem?

As an example of why this is a problem, rsync -a copies the "missing" files on its first run, but for each subsequent run, it doesn't think the file is in the target directory, and so copies it again.

8
  • Output of ls -ld /mnt/seisvault2/data/sac/201402/20140203_220000_MAN please. Jun 20, 2014 at 23:06
  • Is this NFSv3 or NFSv4? Jun 20, 2014 at 23:07
  • Output of the ls -ls command: drwxrwxrwx. 2 nvca223 seismic 20480 Feb 3 17:55 /mnt/seisvault2/data/sac/201402/20140203_220000_MAN
    – geoweaser
    Jun 21, 2014 at 13:23
  • And, I think it's NFSv3: yum --version nfs returns 3.2.29
    – geoweaser
    Jun 21, 2014 at 13:23
  • To get some insight you could try ltrace ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/ and strace ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/ and look for errors like EPERM or EACCESS. Also look of there is any mention of WCI.BH1.IU.10. Jun 23, 2014 at 18:34

2 Answers 2

1

This problem seems to be resolved by a configuration setting under File Sharing / NFS. Originally, I had Operation Mode configured as "User Mode." However, it appears this should be "Kernel Mode."

0

Grep is using regular expressions, of which, '.' happens to be a special character. To demonstrate, imagine I make an empty and do the following:

[root@db test]# touch testfile{1,2,3,4,5}
[root@db test]# touch testfile{1,2,3,4,5}.other
[root@db test]# ls -lah
total 8.0K
drwxr-xr-x  2 root root 4.0K Jun 21 00:43 .
dr-xr-x---. 4 root root 4.0K Jun 21 00:41 ..
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile1
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile1.other
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile2
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile2.other
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile3
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile3.other
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile4
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile4.other
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile5
-rw-r--r--  1 root root    0 Jun 21 00:43 testfile5.other

Now, lets do some grepping! As expected, ls | grep test returns all the files in the directory:

[root@db test]# ls | grep test
testfile1
testfile1.other
testfile2
testfile2.other
testfile3
testfile3.other
testfile4
testfile4.other
testfile5
testfile5.other

But lets say we just wanted the files with a '.' in them:

[root@db test]# ls | grep .
testfile1
testfile1.other
testfile2
testfile2.other
testfile3
testfile3.other
testfile4
testfile4.other
testfile5
testfile5.other

Huh, well that sucks. As mentioned above, '.' has special meaning in regular expressions (namely, match 1 character). How to solve this problem? Backslash comes to the rescue...as the... ESCAPANATOR

[root@db test]# ls | grep '\.'
testfile1.other
testfile2.other
testfile3.other
testfile4.other
testfile5.other

Note that I've put it in single quotes. This will work with double quotes as well -- in most situations (shell expansion can burn you on more complex regexes). If you need to do it without any quotes, you have to escape twice (once for bash, once for grep). It looks like this:

[root@db test]# ls | grep \\.
testfile1.other
testfile2.other
testfile3.other
testfile4.other
testfile5.other
2
  • Thanks for the grep advice. But, this doesn't help me understand the problem. For example, rsync doesn't see the files either. The following should certainly find the file, but it doesn't: ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/ | grep WCI | grep BH1 | grep 10 As with the previous call I showed, this does not return the file.
    – geoweaser
    Jun 21, 2014 at 13:26
  • Yes, this doesn't answer the question. Jun 23, 2014 at 18:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .