0

Suppose that I have a home directory /home/mydir(not have sudo permission),which have some file contain time format (YYYY-MM-DD_HH:MM:SS) in filename, when I try to copy or link these files to a nfs directory, it will report an error,something like

cp: cannot stat './2013010206/NARR_3D:2013-01-03_00': Input/output error
cp: cannot stat './2013010206/NARR_3D:2013-01-03_03': Input/output error
cp: cannot stat './2013010206/NARR_3D:2013-01-03_06': Input/output error
cp: cannot stat './2013010206/met_em.d01.2013-01-02_06:00:00.nc': Input/output error
cp: cannot stat './2013010206/met_em.d01.2013-01-02_09:00:00.nc': Input/output error
cp: cannot stat './2013010206/met_em.d01.2013-01-02_12:00:00.nc': Input/output error
cp: cannot stat './2013010206/met_em.d01.2013-01-02_15:00:00.nc': Input/output error

or

$ cp ~/tests/2013010206/met_em.d03.2013-01-02_12\:00\:00.nc .
cp: cannot stat './met_em.d03.2013-01-02_12:00:00.nc': Input/output error

I think that it is related with the escape characters backslash \ in the time format (12\:00\:00)or say the \: for all file, since when I use this command

$ cp ~/tests/2013010206/met_em.d03.2013-01-02_12\:00\:00.nc met_em_2013-01-02_12
$ ls
met_em_2013-01-02_12

It is ok. So the problem is how to deal with it, it there some setting in the NFS can modify, because this kind of time format file is needed for a lot of my running exe.

And the following is the setting in /etc/fstab

IP:/share1   /share1     nfs     rw,sync,nosuid,rsize=65536,wsize=65536    0 0
| improve this question | |
0

Edit: @AllenZhang : I completely misunderstood your question by reading all nfs's in your question text as NTFS. However, the problem may still be related to NTFS in case that your nfs server is a Windows machine.


Some characters (including " * / : < > ? \ |) are not allowed in file names in an NTFS partition. See Wikipedia Filename topic. Your problem is related to : (the colon) character. You have to replace it with another character while copying.


As a demo, look at the following commands ran on an NTFS volume:

$ touch met_em.d03.2013-01-02_12:00:00.nc 
touch: setting times of 'met_em.d03.2013-01-02_12:00:00.nc': No such file or directory
$ ls met_em.d03.2013-01-02_12:00:00.nc 
ls: cannot access 'met_em.d03.2013-01-02_12:00:00.nc': No such file or directory
$ df .
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sdc1      312568640 264057464  48511176  85% /media/my_user/WD_300GB
$ blkid /dev/sdc1
/dev/sdc1: LABEL="WD_300GB" UUID="2E584CDC584CA505" TYPE="ntfs" PARTUUID="0015bef7-01"
$ sudo file -sL /dev/sdc1
/dev/sdc1: DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS    ", sectors/cluster 8, Media descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 63, dos < 4.0 BootSector (0x80), FAT (1Y bit by descriptor); NTFS, sectors/track 63, sectors 625137281, $MFT start cluster 786432, $MFTMirror start cluster 39071080, bytes/RecordSegment 2^(-1*246), clusters/index block 1, serial number 02e584cdc584ca505; containsMicrosoft Windows XP/VISTA bootloader NTLDR

Compare it with commands ran on an ext4 volume:

$ cd
$ touch met_em.d03.2013-01-02_12:00:00.nc
$ ls  met_em.d03.2013-01-02_12:00:00.nc
met_em.d03.2013-01-02_12:00:00.nc
$ df .
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/sda       479670976 130386736 324848528  29% /home
$ blkid /dev/sda
/dev/sda: LABEL="home filesystem" UUID="91ee80e9-39bc-4521-bd48-46136744435b" TYPE="ext4"
$ sudo file -sL /dev/sda
/dev/sda: Linux rev 1.0 ext4 filesystem data, UUID=91ee80e9-39bc-4521-bd48-46136744435b, volume name "home filesystem" (needs journal recovery) (extents) (64bit) (large files) (huge files)

Going back to our NTFS volume:

$ touch $(echo met_em.d03.2013-01-02_12:00:00.nc | tr ':' '-')
$ ls
met_em.d03.2013-01-02_12-00-00.nc

So, if you want to copy some files from a directory to your NTFS (or nfs) volume, you can use this script, which will replace all colons (:) with underscore (_) characters, while copying:

#!/bin/bash
destination=./your_nfs_directory
for fn in "$@" ; do
  newfn=$(basename "$fn")
  cp -iv "$fn" "${destination}/${newfn//:/_}"
done

Don't forget to replace your real destination nfs directory in the line starting with destination=. The script may be used like the following example:

./script_name ./2013*/*2013-01*

If your file names contain other non-allowed characters, you have to update it to take care of them also.


Note: I remounted the NTFS volume by hand. I suppose this skips some special mount options for Windows compatibility. This time I was able to create a file with a : in it:

$ cd
$ sudo umount /dev/sdc1
$ mkdir /tmp/mountpoint
$ sudo mount /dev/sdc1 /tmp/mountpoint
$ cd /tmp/mountpoint
$ touch met_em.d03.2013-01-02_12:00:00.nc 
$ ls
met_em.d03.2013-01-02_12:00:00.nc
| improve this answer | |
  • Do you mean that there is no options for nfs to allow filenames containing : . Because for my case, it will produce a lot of input or output containing : in the filename when mpirun. – Allen Zhang May 26 '19 at 13:05
  • Not possible AFAIK. I have no experience about mpirun, but can you not configure it so that it will not use these special characters in the file names it create? – FedonKadifeli May 26 '19 at 13:08
  • These file names containing : (or say time) are the standard format of some exe needed. Maybe I need to modify the code, which is a large system. – Allen Zhang May 26 '19 at 13:15
  • I suppose you can remount the ntfs volume with other options as explained in superuser.com/questions/515533/… – FedonKadifeli May 26 '19 at 14:34
  • @AllenZhang I completely misunderstood your question by reading all nfss as ntfs. However, the problem may still be related to NTFS in case that your "nfs server" is a Windows machine. Can you check this? – FedonKadifeli May 26 '19 at 14:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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