DISK or LUN migration to new server with LVM/File systems without loosing the File system Layout and Data, can be implemented in Linux with a sequence simple steps.

Though not necessary, backup existing data as a precaution, especially if you’re migrating a production Volume.

ON SOURCE SERVER

  • Unmount file systems on source server. (Ensure disk is not in use)
  • Deactivate and Export VG
  • Remove file systems entries from /etc/fstab
  • Unpresent LUNs/Disks from source server (from storage end)

  • ON DESTINATION SERVER

  • Present disk / LUN to destination server (from storage end)
  • Scan for LUNS
  • Import and activate VG.
  • scan LVM and mount the file systems on destination server
  • Steps to run on Source server

    #check if file system is being used. If these commands does not produce any result, that indicates that the file system is not being held by any processes.
    lsof /opt/myapps
    fuser -cu /opt/myapps
    
    #unmount File system
    umount /opt/myapps
    
    #deactivate and export VG
    vgchange -an mydata_vg
    vgexport mydata_vg
    
    #Remove the filesystem entry from /etc/fstab file.
    #Shut down the current system.
    #remove LUNS presented to Source server (From storage end)
    

    Steps to run on Destination server

    #Run a LUN scan
    cd /sys/class/scsi_host && for HOST in `ls`; do echo "- - -" > ${HOST}/scan;done
    
    #Check if the LUNS are available
    cat /proc/scsi/scsi
    
    #Import the VG on a destination server.
    vgimport mydata_vg
    
    #Activate the VG on a destination server
    vgchange -ay mydata_vg
    
    #Run below commands to scan for Changes in PV,VG and LV and verify if they are available.
    pvscan
    vgscan
    lvscan
    pvs
    vgs
    lvs
    
    #Crosscheck if LV is activated on the destination server.
    #Add filesystem entry to /etc/fstab file.
    #Mount the filesystems.
    mount -a
    
    #Crosscheck whether it is mounted or not.
    df -Th