Copying Folder while Preserving Permissions/Ownership Error: operation not permitted












1















I am trying to copy a folder while preserving ownership. When I use the command:



sudo cp -R -p /var/lib/mysql /newpath


the files copy but the ownership changes (my username becomes the owner on the new files) and I get an error message saying that cp: failed to preserve ownership for '/newpath/subdirectory' : Operation not permitted for each subdirectory and file in the copied folder. Trying to switch back ownership on the copied files produces the same error (with chown in the place of cp).



sudo chown -R username:group /newpath


I am trying to copy a mysql data directory folder to my second hard drive in such a way that I can then use it as the database directory for the mysql server (username mysql) with webmin.










share|improve this question























  • What is the filesystem type of the second hard drive? If ext2/3/4 does it have any extended attributes set (lsattr /newpath). How is it mounted?

    – steeldriver
    May 5 '14 at 23:09











  • File starts on ext4 and goes to fat32.

    – Michael
    Jun 29 '14 at 1:05
















1















I am trying to copy a folder while preserving ownership. When I use the command:



sudo cp -R -p /var/lib/mysql /newpath


the files copy but the ownership changes (my username becomes the owner on the new files) and I get an error message saying that cp: failed to preserve ownership for '/newpath/subdirectory' : Operation not permitted for each subdirectory and file in the copied folder. Trying to switch back ownership on the copied files produces the same error (with chown in the place of cp).



sudo chown -R username:group /newpath


I am trying to copy a mysql data directory folder to my second hard drive in such a way that I can then use it as the database directory for the mysql server (username mysql) with webmin.










share|improve this question























  • What is the filesystem type of the second hard drive? If ext2/3/4 does it have any extended attributes set (lsattr /newpath). How is it mounted?

    – steeldriver
    May 5 '14 at 23:09











  • File starts on ext4 and goes to fat32.

    – Michael
    Jun 29 '14 at 1:05














1












1








1








I am trying to copy a folder while preserving ownership. When I use the command:



sudo cp -R -p /var/lib/mysql /newpath


the files copy but the ownership changes (my username becomes the owner on the new files) and I get an error message saying that cp: failed to preserve ownership for '/newpath/subdirectory' : Operation not permitted for each subdirectory and file in the copied folder. Trying to switch back ownership on the copied files produces the same error (with chown in the place of cp).



sudo chown -R username:group /newpath


I am trying to copy a mysql data directory folder to my second hard drive in such a way that I can then use it as the database directory for the mysql server (username mysql) with webmin.










share|improve this question














I am trying to copy a folder while preserving ownership. When I use the command:



sudo cp -R -p /var/lib/mysql /newpath


the files copy but the ownership changes (my username becomes the owner on the new files) and I get an error message saying that cp: failed to preserve ownership for '/newpath/subdirectory' : Operation not permitted for each subdirectory and file in the copied folder. Trying to switch back ownership on the copied files produces the same error (with chown in the place of cp).



sudo chown -R username:group /newpath


I am trying to copy a mysql data directory folder to my second hard drive in such a way that I can then use it as the database directory for the mysql server (username mysql) with webmin.







permissions mysql ownership






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 5 '14 at 22:21









MichaelMichael

95216




95216













  • What is the filesystem type of the second hard drive? If ext2/3/4 does it have any extended attributes set (lsattr /newpath). How is it mounted?

    – steeldriver
    May 5 '14 at 23:09











  • File starts on ext4 and goes to fat32.

    – Michael
    Jun 29 '14 at 1:05



















  • What is the filesystem type of the second hard drive? If ext2/3/4 does it have any extended attributes set (lsattr /newpath). How is it mounted?

    – steeldriver
    May 5 '14 at 23:09











  • File starts on ext4 and goes to fat32.

    – Michael
    Jun 29 '14 at 1:05

















What is the filesystem type of the second hard drive? If ext2/3/4 does it have any extended attributes set (lsattr /newpath). How is it mounted?

– steeldriver
May 5 '14 at 23:09





What is the filesystem type of the second hard drive? If ext2/3/4 does it have any extended attributes set (lsattr /newpath). How is it mounted?

– steeldriver
May 5 '14 at 23:09













File starts on ext4 and goes to fat32.

– Michael
Jun 29 '14 at 1:05





File starts on ext4 and goes to fat32.

– Michael
Jun 29 '14 at 1:05










1 Answer
1






active

oldest

votes


















0














FAT32 (or any FAT-type filesystem for that matter) does not support permissions. Any file copied to a FAT filesystem will appear with default owner/group/mode attributes, depending on how the filesystem was mounted.



If you need to preserve these attributes, use a different filesystem. Most (if not all) Unix filesystems (ext*, ReiserFS, btrfs and a bunch of others) supported by Linux will work, so will NTFS to an extent (not strictly a Unix filesystem but designed with a certain degree of Unix compatibility in mind).






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f461403%2fcopying-folder-while-preserving-permissions-ownership-error-operation-not-permi%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    FAT32 (or any FAT-type filesystem for that matter) does not support permissions. Any file copied to a FAT filesystem will appear with default owner/group/mode attributes, depending on how the filesystem was mounted.



    If you need to preserve these attributes, use a different filesystem. Most (if not all) Unix filesystems (ext*, ReiserFS, btrfs and a bunch of others) supported by Linux will work, so will NTFS to an extent (not strictly a Unix filesystem but designed with a certain degree of Unix compatibility in mind).






    share|improve this answer




























      0














      FAT32 (or any FAT-type filesystem for that matter) does not support permissions. Any file copied to a FAT filesystem will appear with default owner/group/mode attributes, depending on how the filesystem was mounted.



      If you need to preserve these attributes, use a different filesystem. Most (if not all) Unix filesystems (ext*, ReiserFS, btrfs and a bunch of others) supported by Linux will work, so will NTFS to an extent (not strictly a Unix filesystem but designed with a certain degree of Unix compatibility in mind).






      share|improve this answer


























        0












        0








        0







        FAT32 (or any FAT-type filesystem for that matter) does not support permissions. Any file copied to a FAT filesystem will appear with default owner/group/mode attributes, depending on how the filesystem was mounted.



        If you need to preserve these attributes, use a different filesystem. Most (if not all) Unix filesystems (ext*, ReiserFS, btrfs and a bunch of others) supported by Linux will work, so will NTFS to an extent (not strictly a Unix filesystem but designed with a certain degree of Unix compatibility in mind).






        share|improve this answer













        FAT32 (or any FAT-type filesystem for that matter) does not support permissions. Any file copied to a FAT filesystem will appear with default owner/group/mode attributes, depending on how the filesystem was mounted.



        If you need to preserve these attributes, use a different filesystem. Most (if not all) Unix filesystems (ext*, ReiserFS, btrfs and a bunch of others) supported by Linux will work, so will NTFS to an extent (not strictly a Unix filesystem but designed with a certain degree of Unix compatibility in mind).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 9 hours ago









        user149408user149408

        561715




        561715






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f461403%2fcopying-folder-while-preserving-permissions-ownership-error-operation-not-permi%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            GameSpot

            connect to host localhost port 22: Connection refused

            Getting a Wifi WPA2 wifi connection