6

I'm trying to copy the Documents and Settings folder of a Windows XP system over to an NTFS external disk using a USB Live of Puppy Linux.

I encountered an encoding problem for namefiles in which the system doesn't recognize italian special characters (part of utf-8) so that using cp or the GUI file manager will bring the error invalid or incomplete multibyte or wide character.

How can I copy the files whose names include the special characters to the NTFS drive?

maja
  • 285
  • how do you mount both filesystems? can you post relevant lines of /proc/mounts or output from mount command? – pqnet Aug 17 '14 at 17:08
  • here you are 'rootfs / rootfs rw 0 0 tmpfs /initrd/pup_rw tmpfs rw 0 0 tmpfs /initrd/mnt/tmpfs tmpfs rw 0 0 /dev/loop0 /initrd/pup_ro2 squashfs ro,noatime 0 0 unionfs / aufs rw,si=c22961e0,xino=/initrd/pup_rw/.aufs.xino,diropq=w,dirs=/initrd/pup_rw=rw:/initrd/pup_ro2=ro 0 0 none /proc proc rw 0 0 none /dev/pts devpts rw 0 0 none /sys sysfs rw 0 0 none /proc/bus/usb usbfs rw 0 0' – maja Aug 17 '14 at 20:45
  • and the important part: '/dev/hda1 /mnt/hda1 ntfs rw,uid=0,gid=0,fmask=0177,dmask=077,nls=iso8859-1,errors=continue,mft_zone_multiplier=1 0 0 /dev/sdb1 /mnt/sdb1 ntfs rw,uid=0,gid=0,fmask=0177,dmask=077,nls=iso8859-1,errors=continue,mft_zone_multiplier=1 0 0 ' – maja Aug 17 '14 at 20:45
  • can you try mounting the two NTFS filesystems without the nls=iso8859-1 option? I think the ntfs driver ignores it, but if not it may be related to your problem. Can you give an example of a file name that can not be copied? – pqnet Aug 18 '14 at 02:38
  • after I tried to use manual mount (whose /proc/mount you can see above) these are all the files that will yield an error: 'cp: cannot create regular file '/mnt/sdb1/CAFFETTIERA --C/Documents and Settings/Amministratore/Amminsitratore/Recent/caffettiera -cc.log.ink' : Permission denied' – maja Aug 19 '14 at 11:24
  • the first attempts were made using Pmount, the mounting tool packaged with PuppyLinux. this is the relevant /proc/mount: '/dev/hda1 /mnt/hda1 fuseblk rw,user_id=0,group_id=0 0 0 /dev/sdb1 /mnt/sdb1 fuseblk rw,user_id=0,group_id=0 0 0' – maja Aug 19 '14 at 11:31
  • when mounting forcing utf-8 /dev/hda1 /mnt/hda1 ntfs rw,uid=0,gid=0,fmask=0177,dmask=077,nls=utf8,errors=continue,mft_zone_multiplier=1 0 0 /dev/sdb1 /mnt/sdb1 ntfs rw,uid=0,gid=0,fmask=0177,dmask=077,nls=utf8,errors=continue,mft_zone_multiplier=1 0 0 the errors are still the same – maja Aug 19 '14 at 14:04
  • example: .../Cookies/4EO0SS6F.txt .../History/History.IE5/MSHist012014081720140818 .../Content.IE5/KH63G1EV/104[1].js .../Recent/SEAGATE 2T (F).lnk the error is always Permission denied – maja Aug 19 '14 at 14:06

3 Answers3

9

Are you sure the file names are valid on the NTFS filesystem?

Do you require that the file names stay the same?

If not, you could remove the "strange" characters to make your live easier:

There is a tool for that, detox.

You can check what would get renamed without changing the filenames first:

$ detox -n somedir/*

And then, actually do it:

$ detox somedir/*



Another approach is to mount the NTFS filesystem in a way that it cleans up ('sanitizes') the file names itself.

There is a mount option to enable this, windows_names:

From man ntfs-3g:

  windows_names
              This option prevents files, directories and extended  attributes
              to be created with a name not allowed by windows, either because
              it contains some not  allowed  character  (which  are  the  nine
              characters  "  * / : < > ? \ | and those whose code is less than
              0x20) or because the  last  character  is  a  space  or  a  dot.
              Existing such files can still be read (and renamed).
Volker Siegel
  • 17,283
  • the files are on a NTFS Windows system partition so I'd say they are valid. I don't really require them to stay the same, but I'm not the only owner of the files and it would be better if they wouldn't change. I think I'll try to get a full list of the problematic file and try a banal GUI copy/paste from windows, hoping that none of them is a system file.. I guess detox may be useful to obtain such a list, thank you. – maja Aug 17 '14 at 15:25
  • The mount option would be better then in that it will apply the minimal changes required only, I guess. – Volker Siegel Aug 17 '14 at 15:31
  • I tried to mount both the output and the input NTFS volumes manually using the windows-names option, checkng the folder proporties from Windows shows that there are 17 less file in the output folder. When i tried to mount the volumes with Puppy Linux GUI Tool and then move the files using the Puppy GUI File Manager I got 162 errors. – maja Aug 17 '14 at 18:21
  • I guess something more then I can see now is going on, I'll try to overwrite the output folder without the `windows-names option but using manual mount and see what happens. If it doesn't work I guess I should find a command that can output which files are "different" between two folders.. – maja Aug 17 '14 at 18:21
3

rsync has an option to change filenames to fit the destination filesystem. from the man page :

--iconv=CONVERT_SPEC

Rsync can convert filenames between character sets using this option. Using a CONVERT_SPEC of "." tells rsync to look up the default character-set via the locale setting. Alternately, you can fully specify what conversion to do by giving a local and a remote charset separated by a comma in the order --iconv=LOCAL,REMOTE, e.g. --iconv=utf8,iso88591. This order ensures that the option will stay the same whether you’re pushing or pulling files.

Try

rsync --iconv=. --archive /source /destination 

Or to specify that the local filesystem is ISO-8859-1,

rsync --iconv=ISO-8859-1,. --archive /source /destination

I couldn't work out how it decides which filesystem is the source and which is the destination when I have both drives mounted locally. But this is the way that worked for me.

1

Add iocharset=utf8 to your mount options, e.g.

mount -o iocharset=utf8 /dev/sdd1 /mnt/external

Now you can copy files to an NTFS partition that violate MS Windows standards.

This will cause problems if you do a chkdsk under Windows on the external drive, but you can just be careful not to trash your filesystem. :-)

ulatekh
  • 111