Tuesday, 28 July 2015

Migrate data using the migratepv command

You can use the logical volume manager (LVM) migratepv command to migrate data that is located on physical volumes. Because you can use this command while the system is active, users are not disrupted.

About this task

The migratepv command moves allocated physical partitions and the data they contain from the source physical volume to one or more destination physical volumes and has the following syntax: migratepv [ -lv LogicalVolumeSourcePhysicalVolumeDestinationPhysicalVolume. The specified physical volumes must all be in the same volume group. The specified source physical volume cannot be included in the list of destination physical volume parameters.

The migratepv command migrates data by performing these actions:
  • Creates a mirror of the logical volumes that you are moving
  • Synchronizes the logical volumes
  • Removes the original logical volume

Procedure

  1. Identify the source disk that contains the data and its volume group.
    # lsdev -Cc disk
    hdisk0    Available 04-08-00-8,0 16 Bit LVD SCSI Disk Drive  <== choose hdisk0 as source disk
    hdisk1    Available 04-08-01-8,0 16 Bit LVD SCSI Disk Drive
    hdisk2    Available 06-09-02     IBM FC 2107
  2. Calculate the amount of space that is currently in use on the disk. This is the total number of physical partitions (PPs) minus the number of free partitions on the disk. In the following example, disk hdisk0 is a member of the rootvg volume group and is using 279 PPs (542 - 263 = 279).
    # lsvg -p rootvg
    rootvg:
    PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
    hdisk0            active            542         263         78..00..00..76..109
  3. Identify destination disk or disks that have enough empty space to accommodate the copied data. If the destination disk or disks are not in same volume group as the source disk, add the destination disk to the source disk volume group using the extendvg command, for example, extendvg rootvg hdisk1. In the following example, disks hdisk0 and hdisk1 are in same volume group and destination disk hdisk1 has 542 free PPs, which is more than the 279 PPs that are required.
    # lsvg -p rootvg;date
    rootvg:
    PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
    hdisk0            active            542         263         78..00..00..76..109
    hdisk1            active            542         542         109..108..108..108..109
  4. You must verify whether the volume group boot image is located on the physical volume that you are moving. You must first Identify the name of the logical volume that contains the boot image. Issue the lsvg -l rootvg command to identify the name of the logical volume that contains the volume group boot image. In this example, partial output listing for the lsvg -l rootvg command shows that for the rootvg volume group, logical volume hd5 has the type boot.
    LV NAME    TYPE   Ps   PPs  PVs  LV STATE        MOUNT POINT 
    hd5        boot   1    1    1    closed/syncd    N/A 
  5. Issue the lslv -l command. to determine whether the boot image is on the source disk. The following example displays the output generated by the lslv -l command. In this case, logical hd5 is located on disk hdisk0, which is the source disk.
    # lslv -l hd5 
       hd5:N/A 
       PV          COPIES         IN BAND       DISTRIBUTION 
       hdisk0      001:000:000    100%          001:000:000:000:000
  6. If the source disk contains the boot image, complete these sub-steps to transfer that boot image to the destination disk.
    1. Issue migratepv -lv hd5 hdisk0 hdisk1 to move the physical partitions in logical volume hd5 that contain the boot image from source disk hdisk0 to destination disk hdisk1.
    2. Issue chpv -c hdisk0 as root user to delete the boot record from the source disk to avoid a potential boot from the old boot image.
    3. Issue the bosboot command to establish disk hdisk1 as the new boot disk.
    4. Issue the bootlist command to designate disk hdisk1, which now contains the boot image, as the boot disk in the boot list.
      # migratepv -l hd5 hdisk0 hdisk1
      0516-1011 migratepv: Logical volume hd5 is labeled as a boot logical volume.
      0516-1246 migratepv: If hd5 is the boot logical volume, please run 'chpv -c hdisk0'
              as root user to clear the boot record and avoid a potential boot
              off an old boot image that may reside on the disk from which this
              logical volume is moved/removed.
      migratepv: boot logical volume hd5 migrated. Please remember to run
              bosboot, specifying /dev/hdisk1 as the target physical boot device.
              Also, run bootlist command to modify bootlist to include /dev/hdisk1.
      
      <<< the following commands taken based on the warning after migrated the boot device 
      
      # chpv -c hdisk0
      # echo $?
      0
      
      # bosboot -ad /dev/hdisk1
      
      bosboot: Boot image is 49180 512 byte blocks.
      # echo $?
      0
      
      
      # bootlist -m normal -o hdisk1
      hdisk1 blv=hd5 pathid=0
  7. Issue the migratepv command to migrate the data from one physical volume to another. Subsequently, you can issue the lsvg -pcommand to verify the results. In this example, after the migration is complete, volume hdisk0 shows 0 PPs because all data that was previously located on physical volume hdisk0 has been moved to physical volume hdisk1.
    # migratepv hdisk0 hdisk1
    # echo $?
    0
    
    # lsvg -p rootvg
    rootvg:
    PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
    hdisk0            active            542         542         109..108..108..108..109
    hdisk1            active            542         263         30..15..01..108..109
  8. After the operation completes, issue the reducevg command to remove the source physical volume from the volume group. In this example, remove physical volume hdisk0 from volume group rootvg.
    # reducevg rootvg hdisk0
    # echo $?
    0
    
    # lsvg -p rootvg
    rootvg:
    PV_NAME           PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
    hdisk1            active            542         263         30..15..01..108..109

Results

After processing is complete, the physical volume is copied to the new location and the LVM no longer accesses the original volume to locate the data that was stored there.

No comments:

Post a Comment