Why does `cp -p` command fail to preserve ownership and permissions while copying files to an External USB flash drive with FAT32 filesystem on RHEL?
Issue
- While copying files using
cp -pcommand from system to an USB flash drive formatted withFAT32filesystem,file ownership/group ownershipandpermissionschange. The option-pdoesn't preserve thepermissions. - Here is the example,
[root@Administrator test]# mkdir first
[root@Administrator test]# chmod 700 first
[root@Administrator test]# chgrp Administrator first
[root@Administrator test]# touch first/file{1..10}
[root@Administrator test]# chmod 777 first/file{1..10}
[root@Administrator test]# chgrp Administrator first/file*
[root@Administrator test]# ls -ld first
drwx------. 2 root Administrator 4096 Mar 2 17:23 first
[root@Administrator test]# ls -l first/
total 0
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file1
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file10
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file2
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file3
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file4
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file5
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file6
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file7
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file8
-rwxrwxrwx. 1 root Administrator 0 Mar 2 17:23 file9
[root@Administrator test]# mkdir /mnt/back;cp -rp first /mnt/back
cp: failed to preserve ownership for `/mnt/back/first/file7': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file5': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file1': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file3': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file6': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file4': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file10': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file2': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file8': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first/file9': Operation not permitted
cp: failed to preserve ownership for `/mnt/back/first': Operation not permitted
[root@Administrator test]# ls -l /mnt/back/
total 16
drwxr-xr-x. 2 root root 16384 Mar 2 17:23 first
[root@Administrator test]# ls -l /mnt/back/first/
total 0
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file1
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file10
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file2
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file3
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file4
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file5
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file6
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file7
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file8
-rwxr-xr-x. 1 root root 0 Mar 2 17:23 file9
Environment
- Red Hat Enterprise Linux (all)
cpcommand with-poption.
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
