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?

Solution Verified - Updated -

Issue

  • While copying files using cp -p command from system to an USB flash drive formatted with FAT32 filesystem, file ownership/group ownership and permissions change. The option -p doesn't preserve the permissions.
  • 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)
  • cp command with -p option.

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content