gsalcedo
asked on
How do I copy files to a NFS mount directory and also preserve the group and user ownership of the files?
Hi,
I am in the process of transferring files from a systems local directory to a NFS mount directory on that same system. In the process of copying the files from the old directory to the NFS mount directory, I receive several messages of "cp: failed to preserve ownership for <file name> : Not owner" . The previous user and group owners have now changed to nobody4 and nogroup in the NFS mount directory. Please assist on the command that I should have used to prevent this from happening? Is there something that I should configure on the NAS system (NetApp)? If there so, please provide a solution. I really appreciate your help.
I am in the process of transferring files from a systems local directory to a NFS mount directory on that same system. In the process of copying the files from the old directory to the NFS mount directory, I receive several messages of "cp: failed to preserve ownership for <file name> : Not owner" . The previous user and group owners have now changed to nobody4 and nogroup in the NFS mount directory. Please assist on the command that I should have used to prevent this from happening? Is there something that I should configure on the NAS system (NetApp)? If there so, please provide a solution. I really appreciate your help.
You need to run the command as root with the "-p" option to cp. In addition, you need to have root access to the NFS mount, which is doesn't sound like you have. In that case, you need to run the cp command from the account of the user that owns those files. You can use the su command to become the user and then run the cp command. When the root user on a system is not set as a trusted root account, you usually find that the files that root creates on the NFS volume end up owned as "nobody"
ASKER
Hi blu,
When I copy the files, I did it as root. The command that I used was cp -pr <file name> <NFS mount directory>. Even as root, I still receive the "cp: failed to preserve ownership for <file name> : Not owner" errors. Is there some options that I am supposed select on the NAS system's NFS export volume, such as Actual Path, Anonymous User ID, Root Access and more?
When I copy the files, I did it as root. The command that I used was cp -pr <file name> <NFS mount directory>. Even as root, I still receive the "cp: failed to preserve ownership for <file name> : Not owner" errors. Is there some options that I am supposed select on the NAS system's NFS export volume, such as Actual Path, Anonymous User ID, Root Access and more?
Correct. The key thing is the "root access". Without root access, the remote root user is treated as an ordinary user, namely the "nobody" user. That means that the attempts to change the owner of the file failed and the file owner was left as "nobody". If you set root access for the remote system, then the root user will be treated as root and not as nobody, and the attempts to chnage the ownership will succeed.
How does your /etc/dfs/dfstab look on the receiving node?
ASKER
Hi Everyone,
The problem was not the options that I indicated with the "cp" command, but the options that I selected on the NFS server (NetApp). One of the options that I had to select was "Anonymous user." After selecting that option and then running the same "cp" command with the "-pr" options, the copy of the files with the right ownership worked just fine. Thank you very much for your advices.
The problem was not the options that I indicated with the "cp" command, but the options that I selected on the NFS server (NetApp). One of the options that I had to select was "Anonymous user." After selecting that option and then running the same "cp" command with the "-pr" options, the copy of the files with the right ownership worked just fine. Thank you very much for your advices.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
1. Make your nfs mount as read write
share -F nfs -o rw,anon=0 /mount
mount it in local as mounttest
copy all files from mount1 to mounttest
cd /mount1; tar cvfp - . | (cd /mounttest; tar xvfp -)
that's all
share -F nfs -o rw,anon=0 /mount
mount it in local as mounttest
copy all files from mount1 to mounttest
cd /mount1; tar cvfp - . | (cd /mounttest; tar xvfp -)
that's all