How to mount a xfs volume to centOS 7 ec2 instance /home directory












0















I created t2.medium instance and attached ebs volume to the instance



Here are some useful information.



sudo pvs



  PV         VG      Fmt  Attr PSize    PFree
/dev/xvdb1 vg_home lvm2 a-- <200.00g 0


sudo vgs



  VG      #PV #LV #SN Attr   VSize    VFree
vg_home 1 1 0 wz--n- <200.00g 0


sudo lvs



 LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
lv_home vg_home -wi-a----- <200.00g


lsblk



NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 50G 0 disk
└─xvda1 202:1 0 50G 0 part /
xvdb 202:16 0 200G 0 disk
└─xvdb1 202:17 0 200G 0 part
└─vg_home-lv_home 253:0 0 200G 0 lvm


lsblk -lf



NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
xvda
xvda1 xfs 0356e691-d6fb-4f8b-a905-4230dbe62a32 /
xvdb
xvdb1 LVM2_member qSmSpW-MRuF-WrUE-jJL8-N182-xOgA-57kdkB
vg_home-lv_home xfs b4fadb7e-714c-4cdd-a5dd-43df5ef19b84


So I need to mount vg_home-lv_home to /home directory.



I can mount this volume by running sudo mount /dev/vg_home/lv_home /home



Then its mounted. After that, I terminated my ssh session and try to ssh again.
ssh -i <key> centos@<ec2_public_ip>. I can't ssh into ec2 instance, error is Permission denied (publickey,gssapi-keyex,gssapi-with-mic).



It makes sense, because I mounted /dev/vg_home/lv_home to /home.
and .ssh folder has gone from /home



Then I restarted the ec2 instance and I can ssh it again.



So my question is how can I mount xfs volume to /home directory?



I created a mountpoint /mnt/home and copied /home then unmounted from mnt/home and mounted to /home. Then I can't connected to ec2 instance at all (with restart).



So what is the best practice/method to mount a volume to ec2 instance /home directory?



-Thank you










share|improve this question














bumped to the homepage by Community 37 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You need to make sure you use cp -a to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.

    – jordanm
    Nov 14 '17 at 0:54













  • hey @jordanm, I'm a newbie to Linux. could you please give me a reference (link/tutorial), please? Thank you

    – Gayan J
    Nov 14 '17 at 1:01













  • I just checked and cp -a alone should cover both permissions and SELinux context labels.

    – jordanm
    Nov 14 '17 at 1:05
















0















I created t2.medium instance and attached ebs volume to the instance



Here are some useful information.



sudo pvs



  PV         VG      Fmt  Attr PSize    PFree
/dev/xvdb1 vg_home lvm2 a-- <200.00g 0


sudo vgs



  VG      #PV #LV #SN Attr   VSize    VFree
vg_home 1 1 0 wz--n- <200.00g 0


sudo lvs



 LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
lv_home vg_home -wi-a----- <200.00g


lsblk



NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 50G 0 disk
└─xvda1 202:1 0 50G 0 part /
xvdb 202:16 0 200G 0 disk
└─xvdb1 202:17 0 200G 0 part
└─vg_home-lv_home 253:0 0 200G 0 lvm


lsblk -lf



NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
xvda
xvda1 xfs 0356e691-d6fb-4f8b-a905-4230dbe62a32 /
xvdb
xvdb1 LVM2_member qSmSpW-MRuF-WrUE-jJL8-N182-xOgA-57kdkB
vg_home-lv_home xfs b4fadb7e-714c-4cdd-a5dd-43df5ef19b84


So I need to mount vg_home-lv_home to /home directory.



I can mount this volume by running sudo mount /dev/vg_home/lv_home /home



Then its mounted. After that, I terminated my ssh session and try to ssh again.
ssh -i <key> centos@<ec2_public_ip>. I can't ssh into ec2 instance, error is Permission denied (publickey,gssapi-keyex,gssapi-with-mic).



It makes sense, because I mounted /dev/vg_home/lv_home to /home.
and .ssh folder has gone from /home



Then I restarted the ec2 instance and I can ssh it again.



So my question is how can I mount xfs volume to /home directory?



I created a mountpoint /mnt/home and copied /home then unmounted from mnt/home and mounted to /home. Then I can't connected to ec2 instance at all (with restart).



So what is the best practice/method to mount a volume to ec2 instance /home directory?



-Thank you










share|improve this question














bumped to the homepage by Community 37 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • You need to make sure you use cp -a to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.

    – jordanm
    Nov 14 '17 at 0:54













  • hey @jordanm, I'm a newbie to Linux. could you please give me a reference (link/tutorial), please? Thank you

    – Gayan J
    Nov 14 '17 at 1:01













  • I just checked and cp -a alone should cover both permissions and SELinux context labels.

    – jordanm
    Nov 14 '17 at 1:05














0












0








0








I created t2.medium instance and attached ebs volume to the instance



Here are some useful information.



sudo pvs



  PV         VG      Fmt  Attr PSize    PFree
/dev/xvdb1 vg_home lvm2 a-- <200.00g 0


sudo vgs



  VG      #PV #LV #SN Attr   VSize    VFree
vg_home 1 1 0 wz--n- <200.00g 0


sudo lvs



 LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
lv_home vg_home -wi-a----- <200.00g


lsblk



NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 50G 0 disk
└─xvda1 202:1 0 50G 0 part /
xvdb 202:16 0 200G 0 disk
└─xvdb1 202:17 0 200G 0 part
└─vg_home-lv_home 253:0 0 200G 0 lvm


lsblk -lf



NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
xvda
xvda1 xfs 0356e691-d6fb-4f8b-a905-4230dbe62a32 /
xvdb
xvdb1 LVM2_member qSmSpW-MRuF-WrUE-jJL8-N182-xOgA-57kdkB
vg_home-lv_home xfs b4fadb7e-714c-4cdd-a5dd-43df5ef19b84


So I need to mount vg_home-lv_home to /home directory.



I can mount this volume by running sudo mount /dev/vg_home/lv_home /home



Then its mounted. After that, I terminated my ssh session and try to ssh again.
ssh -i <key> centos@<ec2_public_ip>. I can't ssh into ec2 instance, error is Permission denied (publickey,gssapi-keyex,gssapi-with-mic).



It makes sense, because I mounted /dev/vg_home/lv_home to /home.
and .ssh folder has gone from /home



Then I restarted the ec2 instance and I can ssh it again.



So my question is how can I mount xfs volume to /home directory?



I created a mountpoint /mnt/home and copied /home then unmounted from mnt/home and mounted to /home. Then I can't connected to ec2 instance at all (with restart).



So what is the best practice/method to mount a volume to ec2 instance /home directory?



-Thank you










share|improve this question














I created t2.medium instance and attached ebs volume to the instance



Here are some useful information.



sudo pvs



  PV         VG      Fmt  Attr PSize    PFree
/dev/xvdb1 vg_home lvm2 a-- <200.00g 0


sudo vgs



  VG      #PV #LV #SN Attr   VSize    VFree
vg_home 1 1 0 wz--n- <200.00g 0


sudo lvs



 LV      VG      Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
lv_home vg_home -wi-a----- <200.00g


lsblk



NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 50G 0 disk
└─xvda1 202:1 0 50G 0 part /
xvdb 202:16 0 200G 0 disk
└─xvdb1 202:17 0 200G 0 part
└─vg_home-lv_home 253:0 0 200G 0 lvm


lsblk -lf



NAME            FSTYPE      LABEL UUID                                   MOUNTPOINT
xvda
xvda1 xfs 0356e691-d6fb-4f8b-a905-4230dbe62a32 /
xvdb
xvdb1 LVM2_member qSmSpW-MRuF-WrUE-jJL8-N182-xOgA-57kdkB
vg_home-lv_home xfs b4fadb7e-714c-4cdd-a5dd-43df5ef19b84


So I need to mount vg_home-lv_home to /home directory.



I can mount this volume by running sudo mount /dev/vg_home/lv_home /home



Then its mounted. After that, I terminated my ssh session and try to ssh again.
ssh -i <key> centos@<ec2_public_ip>. I can't ssh into ec2 instance, error is Permission denied (publickey,gssapi-keyex,gssapi-with-mic).



It makes sense, because I mounted /dev/vg_home/lv_home to /home.
and .ssh folder has gone from /home



Then I restarted the ec2 instance and I can ssh it again.



So my question is how can I mount xfs volume to /home directory?



I created a mountpoint /mnt/home and copied /home then unmounted from mnt/home and mounted to /home. Then I can't connected to ec2 instance at all (with restart).



So what is the best practice/method to mount a volume to ec2 instance /home directory?



-Thank you







centos mount home amazon-ec2 xfs






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '17 at 23:30









Gayan JGayan J

1011




1011





bumped to the homepage by Community 37 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 37 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • You need to make sure you use cp -a to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.

    – jordanm
    Nov 14 '17 at 0:54













  • hey @jordanm, I'm a newbie to Linux. could you please give me a reference (link/tutorial), please? Thank you

    – Gayan J
    Nov 14 '17 at 1:01













  • I just checked and cp -a alone should cover both permissions and SELinux context labels.

    – jordanm
    Nov 14 '17 at 1:05



















  • You need to make sure you use cp -a to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.

    – jordanm
    Nov 14 '17 at 0:54













  • hey @jordanm, I'm a newbie to Linux. could you please give me a reference (link/tutorial), please? Thank you

    – Gayan J
    Nov 14 '17 at 1:01













  • I just checked and cp -a alone should cover both permissions and SELinux context labels.

    – jordanm
    Nov 14 '17 at 1:05

















You need to make sure you use cp -a to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.

– jordanm
Nov 14 '17 at 0:54







You need to make sure you use cp -a to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.

– jordanm
Nov 14 '17 at 0:54















hey @jordanm, I'm a newbie to Linux. could you please give me a reference (link/tutorial), please? Thank you

– Gayan J
Nov 14 '17 at 1:01







hey @jordanm, I'm a newbie to Linux. could you please give me a reference (link/tutorial), please? Thank you

– Gayan J
Nov 14 '17 at 1:01















I just checked and cp -a alone should cover both permissions and SELinux context labels.

– jordanm
Nov 14 '17 at 1:05





I just checked and cp -a alone should cover both permissions and SELinux context labels.

– jordanm
Nov 14 '17 at 1:05










1 Answer
1






active

oldest

votes


















0















  • Make temp directory to mount - sudo mkdir -p /srv/home

  • Mount - sudo mount /dev/vg_home/lv_home /srv/home

  • Copy file from home to temp directory - sudo cp -aR /home/* /srv/home/

  • Check the difference between two directories - diff -r /home /srv/home

  • Afterwards delete all the old content on the /home as follow - rm -rf /home/*

  • Umount from tempdir - sudo umount /srv/home

  • Mount to /home - sudo mount /dev/vg_home/lv_home /home

  • Delete temp mounted directory - sudo rm -r /srv/home/

  • edit /etc/fstab file - /dev/mapper/vg_home-lv_home /home xfs defaults 0 2






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f404345%2fhow-to-mount-a-xfs-volume-to-centos-7-ec2-instance-home-directory%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















    • Make temp directory to mount - sudo mkdir -p /srv/home

    • Mount - sudo mount /dev/vg_home/lv_home /srv/home

    • Copy file from home to temp directory - sudo cp -aR /home/* /srv/home/

    • Check the difference between two directories - diff -r /home /srv/home

    • Afterwards delete all the old content on the /home as follow - rm -rf /home/*

    • Umount from tempdir - sudo umount /srv/home

    • Mount to /home - sudo mount /dev/vg_home/lv_home /home

    • Delete temp mounted directory - sudo rm -r /srv/home/

    • edit /etc/fstab file - /dev/mapper/vg_home-lv_home /home xfs defaults 0 2






    share|improve this answer




























      0















      • Make temp directory to mount - sudo mkdir -p /srv/home

      • Mount - sudo mount /dev/vg_home/lv_home /srv/home

      • Copy file from home to temp directory - sudo cp -aR /home/* /srv/home/

      • Check the difference between two directories - diff -r /home /srv/home

      • Afterwards delete all the old content on the /home as follow - rm -rf /home/*

      • Umount from tempdir - sudo umount /srv/home

      • Mount to /home - sudo mount /dev/vg_home/lv_home /home

      • Delete temp mounted directory - sudo rm -r /srv/home/

      • edit /etc/fstab file - /dev/mapper/vg_home-lv_home /home xfs defaults 0 2






      share|improve this answer


























        0












        0








        0








        • Make temp directory to mount - sudo mkdir -p /srv/home

        • Mount - sudo mount /dev/vg_home/lv_home /srv/home

        • Copy file from home to temp directory - sudo cp -aR /home/* /srv/home/

        • Check the difference between two directories - diff -r /home /srv/home

        • Afterwards delete all the old content on the /home as follow - rm -rf /home/*

        • Umount from tempdir - sudo umount /srv/home

        • Mount to /home - sudo mount /dev/vg_home/lv_home /home

        • Delete temp mounted directory - sudo rm -r /srv/home/

        • edit /etc/fstab file - /dev/mapper/vg_home-lv_home /home xfs defaults 0 2






        share|improve this answer














        • Make temp directory to mount - sudo mkdir -p /srv/home

        • Mount - sudo mount /dev/vg_home/lv_home /srv/home

        • Copy file from home to temp directory - sudo cp -aR /home/* /srv/home/

        • Check the difference between two directories - diff -r /home /srv/home

        • Afterwards delete all the old content on the /home as follow - rm -rf /home/*

        • Umount from tempdir - sudo umount /srv/home

        • Mount to /home - sudo mount /dev/vg_home/lv_home /home

        • Delete temp mounted directory - sudo rm -r /srv/home/

        • edit /etc/fstab file - /dev/mapper/vg_home-lv_home /home xfs defaults 0 2







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '17 at 3:53









        Gayan JGayan J

        1011




        1011






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f404345%2fhow-to-mount-a-xfs-volume-to-centos-7-ec2-instance-home-directory%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

            CARDNET

            Boot-repair Failure: Unable to locate package grub-common:i386

            濃尾地震