Saturday, July 8, 2017

Step by Step Move LVM ( VG-Volume Group , PV-Physical Voulme and LV- Logical Volume) to another Linux System

LVM Move: - We can move entire LVM Volume group to another Linux System. 
It may require when you are going to upgrade your current OS to the latest or there is some issue with current Server hardware or going to use new server hardware.



Why Move LVM: -
1- There is some hardware issue with current server
2- We have new Server hardware
3- Current OS is old version

Prerequisites:- 
1- A user with sudoers access over old System
2- user with sudoers privileges over new System
Move LVM: - We need to perform following steps to move LVM

My Current scenario as follows:
VG Name:  VG01






PV Name:  /dev/sdb1 and /dev/sdc1 







LV Name:  LV01 and LV02 








 Note: -first, make sure no one is accessing the file on the active volume in the volume group we are going to move.
Step 1: -  Unmount LV logical volume
Before, we start moving LVM need to unmount let's use below command to unmount LV
root@Server16:~# umount /mnt/FLV
Step 2: - Make VG inactive 
Now we need to make VG inactive, use below command.
root@Server16:~# vgchange -a n VG01
Step 3: - Export Volume Group
root@Server16:~# vgexport VG01
Volume group VG01 is exported
Cannot process volume group VG01
After exporting VG, the Physical Volume will show up as being exported volume group when you will execute command pvscan.








Step 4: - Shutdown System and unplugged disk
After System Shutdown unplugged both the disk. Let's use init 0 command to shutdown system.

Step 5: - Plugged disk to new system and power it on 
After putting both the disk to the new system, I am going to power it on and will show you how to import Volume Group.
Disk , VG and LV details as follows:

























Step 6: - VG Import 
After putting all the disk to new system we need to import Volume Group, let's use below command to Import VG using command vgimport

root@US16:~# vgimport VG01
  Volume group "VG01" successfully imported

Step 7: - Activate Volume Group
After successful import of VG, We need to active Volume Group using command below
root@US16:~# vgchange -a y VG01
  2 logical volume(s) in volume group "VG01" now active
Step 8: - Create mount point 
Now Volume Group has successfully import and activated, let's create mount point so we can mount and start using Logical Volume.
root@US16:~# mkdir /mnt/lvm1
root@US16:~# mkdir /mnt/lvm2
Mount point successfully created.
Step 9: - Mount Logical Volume
root@US16:~# mount /dev/VG01/LV01 /mnt/lvm1/
Step 10:  Check old data of LV01 Logical Volume
Volume Group Import has done successfully, and Logical Volume mounted as well.
let's check existing data in the mounted LV.










Volume Group has successfully Imported to new system and working as expected. We can make fstab entry to mount Logical Volume permanently.
Step 11: - Make Fstab entry to mount LV permanently
Let's use below command to mount it permanently.
root@US16:~# vi /etc/fstab
Append line below in the end of fstab file
/dev/VG01/LV01  /mnt/lvm1       ext4    errors=remount-ro 0     0
Your fstab file looks like below


















Step 12: - Use command mount -a to apply changes
After making change in fstab file we need to restart system to apply changes, but we can use command mount -a to apply changes without restart system.
root@US16:~# mount -a
Logical Volume has been successfully mounted permanently.

!!!That's all about VG Moving!!!! Thank you so much for reading.

No comments:

Post a Comment