Linux – Restore file permissions after rsync on ntfs

linuxntfsrsync

When messing around with partitions under Windows when I tried to format empty space of the hard drive to have it in Windows, I messed something up and cfdisk told me that all the partitions did not start at the right physical boundaries, and I would face performance drops. Also swap was hanging on the wrong partition and Windows crashed on boot.

Well, I was not able to fix it but since I had an rsynced backup of my main arch linux system (rsync -aAXv / /mnt/ext) I dared to delete all partitions, create new ones, and put the backup back on the recreated linux partitions.

I mounted the backup external disk but it got mounted with 777 permissions. Before I noticed how it was mounted, I rsynced everything back and then noticed that my whole linux system is on 777 and everything owned by root. All files are there, the installation even boots up, but of course I can not work with everything, even home is owned by root with 777 permissions.

So, is there a way to, either mount the NTFS external disk with the old permissions, or restore the default permissions somehow else?

Thank you

PS: Forgot to mention but maybe interesting to know, that I did the first partition attemt on windows, thats why the partitions got messed up. Root and /home appeared as SFS and the windows-partition got "shifted" to sda3 where swap was earlier, so linux mounted the windows partion as swap what made windows crashing with BSOD on bootup.

Best Answer

NTFS in particular is a bad choice for taking filewise backups of linux systems, because it uses windows' ACL model for permissions rather than the UNIX model. In consequence, the permissions on these volumes are determined by the mount options. Therefore, when you took the backup, you didn't back up the permissions metadata (permission bits or ownership).

See dawud's (automated) comment for why you can't restore "default" permissions (the short answer: there is no such thing), and some thoughts on what you might be able to do to recover (it will be long and tedious).

If you have windows stuff backed up to that NTFS disk also, the permissions metadata should be intact.