Maintaining Ownership When Copying Files and Directories

Nigel Wade nmw at ion.le.ac.uk
Tue Apr 3 14:48:08 UTC 2007


Sean McGlynn wrote:
> Hello,
> 
> On a RHEL4 server I have mounted a directory from another RHEL4
> server.  I want to copy the files from the mounted directory,
> maintaining ownership and permissions.  When I attempt to do a copy
> as root I get a permission denied message.  When I do a cp -r
> --preserve=all as a user who is a member of a group who has rights to
> the directory I am able to do the copy, the permissions are
> maintained, but the ownership is not.  This makes sense as the man
> page for cp say you need to be root to change ownership.  So how can
> I make this happen if I can't do it as root?  The group is maintained
> in eDirectory, so I can't add root to the group.
> 
> Thank you.
> 
> 

You probably need to set the no_root_squash on the export.

By default root permission is not maintained across NFS mounts. This is 
to prevent an administrator on the NFS client reading files to which 
they should not have access, writing where they should not be able to 
and, worst of all, planting suid root executables to run on the server.

However, if you administer both client and server you can override this 
and give yourself root access to the server's files on the client using 
the no_root_squash in the export options.

Be very careful unless you are the only person with root access to all 
the NFS hosts.

-- 
Nigel Wade, System Administrator, Space Plasma Physics Group,
             University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw at ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555




More information about the redhat-list mailing list