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
cp -a
to preserve permissions. You also likely need to temporary disable SELinux and set relabel the files in the new volume.cp -a
alone should cover both permissions and SELinux context labels.