1

I have a volume group called 'encrypted' and its device name is /dev/xvdj.

[root@s-mysql /]# lsblk
xvdj                     202:144  0   3T  0 disk
└─xvdj1                  202:145  0   3T  0 part
  ├─encrypted-home_vol  253:6    0   2G  0 lvm  /home
  ├─encrypted-local_vol 253:7    0   2G  0 lvm  /usr/local
  ├─encrypted-opt_vol   253:8    0   4G  0 lvm  /opt
  ├─encrypted-tmp_vol   253:9    0   4G  0 lvm  /tmp
  └─encrypted-var_vol   253:10   0   3T  0 lvm  /var

I have another disk. This disk is also LVM and its group name is also called encrypted due to the way the disk was created. I want to do the following:

create a symlink from new_disk (/var/lib/mysql) to old_disk (/var/lib/mysql)

So I did the following.

# rename the old encrypted to old
vgrename encrypted old

# update cahce
pvscan --cache

At this point I have

[root@s-mysql /]# lsblk
NAME                     MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
...
xvdf                     202:80   0   3T  0 disk
└─xvdf1                  202:81   0   3T  0 part
xvdj                     202:144  0   3T  0 disk
└─xvdj1                  202:145  0   3T  0 part
  ├─old-home_vol  253:6    0   2G  0 lvm  /home
  ├─old-local_vol 253:7    0   2G  0 lvm  /usr/local
  ├─old-opt_vol   253:8    0   4G  0 lvm  /opt
  ├─old-tmp_vol   253:9    0   4G  0 lvm  /tmp
  └─old-var_vol   253:10   0   3T  0 lvm  /var

Notice /dev/xvdf is still not mounted yet. I hope so far make sense.

[root@s-mysql /]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdf1
  VG Name               encrypted
  PV Size               <3.00 TiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              786431
  Free PE               13056
  Allocated PE          773375
  PV UUID               TSeqC4-EsEA-NBYf-3ACd-aNh7-9q7o-Op5yJU

  --- Physical volume ---
  PV Name               /dev/sdj1
  VG Name               old
  PV Size               <3.00 TiB / not usable 2.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              786431
  Free PE               15359
  Allocated PE          771072
  PV UUID               usM0iR-1eGw-CeC8-BQd3-Hr9I-BezY-PRyp1K

Now, if I mount, I get this:

[root@s-mysql /]# vgchange -a y
  6 logical volume(s) in volume group "encrypted" now active
  5 logical volume(s) in volume group "old" now active
[root@s-mysql /]# lsblk
NAME                    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda                    202:0    0   8G  0 disk
└─xvda1                 202:1    0   8G  0 part /
xvdb                    202:16   0  25G  0 disk
└─xvdb1                 202:17   0  25G  0 part
xvdf                    202:80   0   3T  0 disk
└─xvdf1                 202:81   0   3T  0 part
  ├─encrypted-home_vol  253:0    0   2G  0 lvm  /home
  ├─encrypted-local_vol 253:1    0   2G  0 lvm  /usr/local
  ├─encrypted-opt_vol   253:2    0   4G  0 lvm  /opt
  ├─encrypted-tmp_vol   253:3    0   4G  0 lvm  /tmp
  ├─encrypted-var_vol   253:4    0   3T  0 lvm  /var
  └─encrypted-usr_vol   253:5    0   9G  0 lvm
xvdj                    202:144  0   3T  0 disk
└─xvdj1                 202:145  0   3T  0 part
  ├─old-home_vol        253:6    0   2G  0 lvm  /home
  ├─old-local_vol       253:7    0   2G  0 lvm  /usr/local
  ├─old-opt_vol         253:8    0   4G  0 lvm  /opt
  ├─old-tmp_vol         253:9    0   4G  0 lvm  /tmp
  └─old-var_vol         253:10   0   3T  0 lvm  /var

This is not good. We have /var. My question is how do I just mount "/var/lib/mysql" from the new disk /dev/xvdf and create a symlink so I can replace the old /var/lib/mysql now given they both present /var?

0

You can create different mountpoint (for example /var2), mount there the desired LV, remove current /var/lib/mysql and create the softlink

ln -s /var2/lib/mysql /var/lib/mysql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.