But why?...And how to fix this?
Some people claim that EXT is not compatible with NTFS, but that's only the half story.
In fact: the most popular application like cp, nautilus or samba copy very well, but still with data loss.
But the only reason why there occurs data loss is, because in the EXT3/4 file system there are a lot of more characters in the file/dir names allowed.
On a EXT file system it is possible to use to following characters: \ : * ?" < > |
... which is forbidden on the NTFS fs. --> DATA LOSS
And also all controll characters and even the new line characters are forbidden in NTFS. (which is not in ext3/4 and nautilus can handle it as well)
This are all characters from 0x00 - 0x1F (ASCII encoding). --> DATA LOSS
Also in EXT3/4 the files/dirs names may end with an empty space and therefore this files/dirs will be treated as 2nd files/dirs. In NTFS, the WinExplorer (Windows 7) will make no difference of both and on the next windows scan disc theese files will be removed! --> DATA LOSS
Example:
If you copy it now then this files/dirs will remain: (nautilus and cp)
Samba showed the best result, but still not perfect:
at least, samba copied everything, so this means no data loss!
But with ugly names.
Here you can read more:
So here is the only final possible solution to move files from ext to ntfs.
Implement an Application (or use mine) which iterates over every file in your ext file system and renames every invalid ntfs filename into a valide filename.
Both (ext3/4 and ntfs) sopport Unicode!
Map all characters which are allowed in ext but not in ntfs from ascii to an unicode synonym.
| ASCII | UTF-8 (hex) | Appereance |
| \ | 0x2572 | ╲ |
| : | 0xFF1A | : |
| * | 0x2731 | ✱ |
| ? | 0xFF1F | ? |
| " | 0x201D | ” |
| < | 0xFF1C | < |
| > | 0xFF1E | > |
All ASCII characters from 0x00 - 0x1F are controll characters, if there exist a filename which such a character, then remove this. 0x1A is the newline character, you may wan't to replace this with space instead remove.
The following are also controll characters which are not betweene 0x00 and 0x1F:
0x7F, 0x81, 0x8D, 0x8F, 0x90, 0x9D
...but you also have to remove this to make it valid for ntfs.
Then you have to check if there are two files like this:
1.File: "text.txt"
2 File: "text.txt "
(note the whitespace in File 2!)
you should rename one of theese files to to "text.txt (1)". Just make sure, that they don't have the same filename! (NTFS don't like whitespaces at the end of a filename)
In conclusion this are 3 steps you have to consider while implementing your app:
- Use UTF-8 encoded characters for invalid ntfs characters. ( \ : * ?" < > | )
- Remove not printable controll characters!
- Rename one of theese files: "text.txt" and "text.txt "
Here is my java application which you can use to convert all filenames in a directory / parition:
Before:
After:
Download here: http://code.google.com/p/ext2ntfs-compatibilator/
This Application only need 3 simple java classes, all 3 classes use together only about 300 lines of code (included +30% comments).
An experient java programmer will understand this code in less then 10 min.



No comments:
Post a Comment