[CS-FSLUG] Copying files and permissions

Tim Young Tim.Young at LightSys.org
Mon Apr 12 19:15:26 CDT 2010


Hi there,
There are a number of issues involved.
*The short answer* is that you want to use "tar" as the root user if you 
are going to copy the files off, let them reside on a temporary (and 
different filesystem) and then restore them later.

(If I misunderstood what you were doing and were copying windows files, 
I will add this note:)  If you are copying from an NTFS and restoring to 
an NTFS, then you may be in trouble if you want to retain NTFS 
permissions.  Linux basically ignores NTFS file permissions, both in 
reads and writes.  If you are going to backup windows files and restore 
them with their original permissions, you need to use "dd" (or another 
disk imaging system) or use a windows-based tool.  I believe that even 
the mcopy tool, while copying retaining the MS attributes, loses the 
ownership of the file.

*For backing-up Linux files & restoring them on Linux*:
VFAT and NTFS do not store the same file permissions that linux uses.  
So when you write individual files to either of those filesystems, all 
your file permissions are irretrievably lost.  Regardless of the copy 
tools you use, because the filesystem is not capable of storing the file 
permissions, you are fighting a losing battle.  "Tar" makes a single 
file, inside of which it retains all the file permission and ownership.  
When you restore the files from a tarball, if you are root, it will 
restore all the original owner, and permissions.  If you are not root, 
it will restore with different variations of the permissions, depending 
on what the permissions were.  You can use cpio (another "tar" like 
linux command-line program) too, though most people now-days are more 
familiar with tar.

If you store linux files temporarily on a linux partition instead of a 
windows one, there are lots of ways to do it.  Rsync has the -a flag 
(for archive) which will preserve all permissions and ownership.  Ftp, 
cp, scp, and all, each have their options to retain permissions.  Just 
so long as you are going from a Linux filesystem to a Linux filesystem 
you are fine.

     - Tim

On 4/12/2010 6:42 PM, sjm wrote:
> Ed Hurst wrote:
>> Permissions I get, as well as chmod and the octals. What I don't get 
>> is how I can copy large numbers of files and directories from a VFAT 
>> jump drive or NTFS external harddrive without having to go back and 
>> ding around with permissions.
>>
>> I have a nice 250GB external drive someone gave me, and I use it when 
>> helping folks with computer problems. Recently, an owner asked me to 
>> install Ubuntu on their machine. Pulled all the files off onto the 
>> NTFS drive, installed Ubuntu, the copied them all back. With my 
>> limited knowledge, I knew I'd either have to copy as is, and have 
>> everything tagged with execute bits set, or copy with MC, turn off 
>> the "keep attributes" and end up with 0600 on everything, including 
>> folders.
>
> Same a Josiah, I don't have something nearby to test, but a couple of 
> thoughts:
>
> - format part of the external drive as ext3 for future use.  (And I 
> usually use rsync for copying with permissions saved so I can pick up 
> later where I left off if the connection fails.)  Remember that 
> permissions are by uid and gid, so if those change between boxes, 
> saved permissions would need ownership changed anyway.
>
> - What trouble are you having with chmod -R?  (Remember that X (not x) 
> only sets executable for those that are already executable.)
>
> - I like cwRsync for Windows though can't remember how permissions 
> transfer right now.
>
> - Tim Young probably has a better answer. :)
>
> sjm
>
>
> _______________________________________________
> ChristianSource FSLUG mailing list
> Christiansource at ofb.biz
> http://cs.uninetsolutions.com
>




More information about the Christiansource mailing list