16

I try to copy all files from an NTFS to an external drive and want to preserve all permissions and attributes. The external drive has already an NTFS and contains other files.

I've considered using the following tools:

  • ntfsclone does not work since it operates on sector level and would clone the whole FS, thus destroying the old data. If used to create an image file, I can't access the content from a Windows machine.
  • rsync does not preserve all meta data.

An alternative would be to use robocopy inside a running Windows, but I would prefer to copy the files without. (The source partition is used as the system's C:\.)

How can I copy the files?

Scolytus
  • 344

4 Answers4

9

There is no way to exactly copy NTFS files, passing through Linux. Even Wine, the Windows-compatibility layer on Linux, works by converting permissions back-and-forth between Linux and Windows, and so is limited to their (rather small) least common denominator.

The only solution I can see is running Windows on Linux inside a virtual machine (or physical).

I believe you have mentioned this possibility in your post and would prefer to avoid it, but I do not see another possibility. Only Windows can exactly copy NTFS files; Linux is only capable of copying NTFS partitions.

This article might help: How to install and run Microsoft Windows for free on Linux, using free virtual machines made available for download by Microsoft.

harrymc
  • 498,455
1

Linux can copy NTFS files contents fine, just not all the modified/created/accessed dates & attributes (I'm assuming that's what you want preserved).

So why don't you just make note of the current dates & attributes (dir should be able to display them), then copy the files in linux, and once you're running Windows again change the dates & attributes back to the originals.

Use a tool in Windows that can change the files, like one of these ones:

Apparently Windows' own File Explorer doesn't even preserve all the file dates properly either. But zip & cygwin's tar commands should save file dates, so using one of those in Windows to create an archive first should work too, then just copy the archive any old way.


If the attributes are super-important, and difficult to copy even in Windows, they should probably be backed up in a text file or database, or made into part of the filename...

Xen2050
  • 14,391
1

First thing is, you need to make up your mind if you want to copy files, ...

or you want to make a complete, sector-by-sector, copy of your NTFS partition, including the "old data", the "other files", aswell "all the metadata" you have mention above very broadly.

For the latter, use dd:

dd if=/dev/sda2 of=/mnt/usbdisk/my-ntfs-partition-D.img bs=1M

Have fun.

Paxsali
  • 313
0

UPDATE 2023.08.08: cp and rsync still don't work out of the box. But tar still does and tar can be piped. This will keep timestamps. (Except maybe for ctime.)

See How to tar/untar the output on the fly

Dennis
  • 1