6

I tried to synchronize /dir1 (ext4) and /dir2 (ntfs) using rsync -azP, but got these errors:

rsync: recv_generator: mkdir "dir2/X.Y." failed: Invalid argument (22)

rsync: recv_generator: mkdir "dir2/CATSNDOGS\#123.11." failed: Invalid argument (22)

Note that directories X.Y. and CATSNDOGS #123.11. are created by other party and, named as they are, downloaded (using Python script) to /dir1.

I can't cd into these directories and ls -d doesn't list them. On the other hand, GUI-based nautilus shows both them and content inside them perfectly.

3
  • 1
    What is the filesystem type of the target directory?
    – schily
    Feb 4, 2021 at 21:34
  • 1
    Please show your rsync command
    – cryptarch
    Feb 4, 2021 at 22:06
  • I've edited the question.
    – Igor V.
    Feb 4, 2021 at 22:21

2 Answers 2

8

The problem is that rsync is trying to create directories in a NTFS partition with illegal characters. From Naming Conventions

Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

The following reserved characters:   
 > (less than)
 < (greater than)   
 : (colon)   
 " (double quote)   
 / (forward slash)   
 \ (backslash)   
 | (vertical bar or pipe)   
 ? (question mark)   
 * (asterisk)

Also

Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. However, it is acceptable to specify a period as the first character of a name. For example, ".temp".


Your failed directories have, or illegal characters or end with a period.

4
  • Thanks (again)! It's incredible how these "little" things can give you huge headaches. Do you have an idea how to circumvent it automatically (even if it does mean changing the name)?
    – Igor V.
    Feb 5, 2021 at 21:46
  • 1
    @IgorV. mmh, the thing is that rsync is the command that creates the directories, I don't know if you can rename them from it. So, unless there's a way with rsync, you would have to rename them before running the command. A command that could work to do precisely that is something like this: for i in */; do mv "$i" "$(echo "$i" | sed 's:\.$\|[ <>:"/\|?\*]::g')"; done, but you would have to try it in your setup. Feb 5, 2021 at 22:23
  • 1
    @IgorV. Note that the command I just gave you could lead to duplicate names, which will result in error. Feb 5, 2021 at 22:27
  • The link to your naming conventions is clear. But I have no problem to create a folder on my Windows10 machine with an ' in name. Isn't that illegal because of the naming conventions?
    – buhtz
    Nov 28, 2022 at 15:56
0

Late answer, but this will help, I had a similar issue to the one here(rsync: [sender] readlink_stat was returning failed: Invalid argument (22)). The folder also wasn't showing in Dolphin. I dismounted the NTFS drive and ran chkdsk drive: /r /f on it in Windows and fixed the problematic folder, which was orphaned, along with numerous other unindexed and orphaned files with contracted names such as FILE~2.TXT. It also fixed errors like 'The VCN of index in file is already in use. Back onto Linux rsync worked without issues.

Additionally in dmesg/journalctl -ke I found hundreds of "nftfs3: sdb2: ino=1dc0 "Folder" directory corrupted" errors.

You must log in to answer this question.

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