FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Sun Jun 13, 2021 00:57



Post new topic Reply to topic  [ 6 posts ] 
Copying Between NTFSes With Preserving Permissions 
Author Message

Joined: Wed Aug 08, 2012 05:28
Posts: 4
Post Copying Between NTFSes With Preserving Permissions
I've not been able to find an answer to this specific question so I'm hoping someone here can point me in the right direction.

I have two NTFS volumes in the machine and I want to copy all of the files from one to the other while preserving permissions, hereditary or otherwise. How can I do this in Linux with ntfs-3g? I tried using robocopy in Windows, but that can't copy the files that are open, so ideally I want to boot into a Linux LiveCD, mount both disks, and copy everything to the new disk. I have a suspicion, however, that plain old Linux methods (cp -a or tar) won't preserve the permissions on the copied files. Is that the case? If so, how do I preserve the permissions on the copied files?

TIA


Wed Aug 08, 2012 05:34
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Copying Between NTFSes With Preserving Permissions
Hi,

Quote:
I have two NTFS volumes in the machine and I want to copy all of the files from one to the other while preserving permissions, hereditary or otherwise. How can I do this in Linux with ntfs-3g?

Within http://b.andre.pagesperso-orange.fr/tools.zip there is a program ntfscp.c and two shell scripts ntfscp.sh. Each of them copy a subtree of files along with all their attributes including ownerships and permissions.
Quote:
so ideally I want to boot into a Linux LiveCD, mount both disks, and copy everything to the new disk.

If you want to clone an old disk to a new one, you can also use ntfsclone. This will create a new file system the same size as the old one, which you may later adjust to the wanted size by ntfsresize.
Quote:
I have a suspicion, however, that plain old Linux methods (cp -a or tar) won't preserve the permissions on the copied files. Is that the case? If so, how do I preserve the permissions on the copied files?

Doing the copy this way requires that the owners and groups of all the needed files are mapping to Linux users and groups.

Regards

Jean-Pierre


Wed Aug 08, 2012 09:51
Profile

Joined: Wed Aug 08, 2012 05:28
Posts: 4
Post Re: Copying Between NTFSes With Preserving Permissions
Thanks for the top, using the tools archive sounds like just what I need. Will give it a go shortly.

Ntfsclone was the first thing I tried, but the problem is that the old disk has 512b sectors and the new disk is an iSCSI share that has 4KB sectors (no 512b sector emulation). This seems to result in things being broken after copying using ntfsclone - Windows ends up seeing the disk as unpartitioned and unformatted.


Wed Aug 08, 2012 14:44
Profile

Joined: Wed Aug 08, 2012 05:28
Posts: 4
Post Re: Copying Between NTFSes With Preserving Permissions
Curioser and curioser. When using 4KB sector disks everything goes weird. And I mean WEIRD. Perhaps somebody here can help me figure this out.

What I'm trying to do is copy my existing Windows partition to a new partition, and get it virtualized (fed up of having to reboot into Windows every once in a while when 99% of my work involves Linux).

I have ZFS backed volume with 4KB blocks, which I am exporting via iSCSI, and I want to use this for my VM disk.

Here is the matrix of failures:

1) Partition + Format in Windows: Viewable, but not bootable in the VM (closest I could get is ntldr not found message, even though it is there). Booting VM into XP disk recovery console results in "dir" on C: drive showing a single garbled file entry. Not good.
2) Partition + Format using ntfsprogs: Exactly the same result as 1).
3) When starting the installer with partition/FS created using 1) or 2) the FS looks 16MB big, with a large empty space after it (?!?!?!)

The only way I have been able to get something bootable on this 4KB sector iSCSI share (in VMware) is to do a clean Windows XP x64 install. Now, I could just about live with that if I could then copy my files back over - but I can't! When I connect this iSCSI share to Windows, it sees the partition as unformatted! The same partition that the installer built while installing. Bizzare.

In Linux, ntfsprogs has a similar problem - it won't mount (doesn't recognize the file system).

But the same raw disk image boots 100% fine under VMware Player.

Either something deeply bizzare is going on, or I am doing something unbelievably wrong. Having spent the last 2 days fighting this, I am not longer even sure the latter isn't the case.

Anybody got any thoughts at all on how I might get this NTFS on 4KB sector disk image to mount?


Wed Aug 08, 2012 19:05
Profile

Joined: Wed Aug 08, 2012 05:28
Posts: 4
Post Re: Copying Between NTFSes With Preserving Permissions
Here is what I get in Linux when I try to mount this partition:

# mount -o ro -t ntfs-3g /dev/sdc1 /mnt/windows.new
ntfs_mst_post_read_fixup: magic: 0x004d020c size: 4096 usa_ofs: 83 usa_count: 72: Invalid argument
Record 0 has no FILE magic (0x4d020c)
Failed to load $MFT: Input/output error
Failed to mount '/dev/sdc1': Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it's a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation
for more details.

The even more fascinating thing is that I have a similar configuration on a different system (VMware Player with iSCSI 4KB/sector image), and that doesn't exhibit any similar issues - I can mount that using ntfsprogs just fine. But on this system it seems the only way to have a bootable image results in the image not being accessible from anything else.

The only other thing I can think of is that there is some leftover bit of garbage data on the iSCSI volume confusing things (I'd previously tried to clone to this volume using ntfsclone, gparted, dd and a few other tools. So I might try blowing away the iSCSI target volume and re-creating a fresh one.


Wed Aug 08, 2012 19:23
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: Copying Between NTFSes With Preserving Permissions
Hi,

Quote:
What I'm trying to do is copy my existing Windows partition to a new partition, and get it virtualized (fed up of having to reboot into Windows every once in a while when 99% of my work involves Linux).

Please make a distinction between transferring files to a new disk with a different sector size, and getting Windows to boot from the new disk. A new Windows driver may be needed for it to boot, and some Windows files may have to be adjusted to the new configuration, so some system recovery program must be started.
Quote:
2) Partition + Format using ntfsprogs: Exactly the same result as 1).

To format and access a 4K sector partition you must use ntfs-3g-2012.1.15 or later. Older ntfs-3g and ntfsprogs are not compatible with Windows.
Quote:
the FS looks 16MB big, with a large empty space after it (?!?!?!)

What do you mean ? Just after formatting only metadata files are created. Also it is not clear to me whether the new ntfs file system sits on the real disk or on a virtual disk (which would be a sparse file).
Quote:
The only way I have been able to get something bootable on this 4KB sector iSCSI share (in VMware) is to do a clean Windows XP x64 install. Now, I could just about live with that if I could then copy my files back over - but I can't! When I connect this iSCSI share to Windows, it sees the partition as unformatted! The same partition that the installer built while installing.

Your old Windows may be missing some driver required to access the new disk.
Quote:
In Linux, ntfsprogs has a similar problem - it won't mount (doesn't recognize the file system).

What are the partitioning parameters ? What is the output of "fdisk -l" ?
Quote:
Anybody got any thoughts at all on how I might get this NTFS on 4KB sector disk image to mount?

Try (using ntfs-3g-2012.1.15, or better ntfs-3g-2012.1.15AR.6 from http://www.tuxera.com/community/ntfs-3g-advanced/), and post the outputs of :
Code:
mkntfs -f -s4096 -c4096 /dev/sdc1
ntfsfix /dev/sdc1
ntfsinfo -m /dev/sdc1

Quote:
ntfs_mst_post_read_fixup: magic: 0x004d020c size: 4096 usa_ofs: 83 usa_count: 72: Invalid argument

This does not look like an ntfs formatted partition, please post the bootsector (compression required to post attachments on this forum).
Code:
dd if=/dev/sdc1 of=bootsector.img bs=4096 count=1
gzip bootsector.img

Quote:
The only other thing I can think of is that there is some leftover bit of garbage data on the iSCSI volume confusing things (I'd previously tried to clone to this volume using ntfsclone, gparted, dd and a few other tools. So I might try blowing away the iSCSI target volume and re-creating a fresh one.

If the partition is clean, you should format it again as ntfs (gparted relies on ntfs-3g, it would format wrongly if you have an old ntfs-3g). If formatting is not enough, you may have to redo the partitioning.

Regards

Jean-Pierre


Thu Aug 09, 2012 10:14
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.