Replacing Disks with replacepv

Edit: Some links no longer work.

Originally posted November 17, 2015 on AIXchange

IBM developerWorks recently posted this piece about replacing a boot disk in PowerVC.

The developerWorks article mentions the replacepv command, using an example where this was run:

    replacepv hdisk0 hdisk1

I haven’t messed around with replacepv, but once I read about its capabilities, I was impressed:

The replacepv command replaces allocated physical partitions and the data they contain from the SourcePhysicalVolume to DestinationPhysicalVolume. The specified source physical volume cannot be the same as DestinationPhysicalVolume.

Note:
    The DestinationPhysicalVolume must not belong to a volume group.
    The DestinationPhysicalVolume size must be at least the size of the SourcePhysicalVolume.
    The replacepv command cannot replace a SourcePhysicalVolume with stale logical volume unless this logical volume has a non-stale mirror.
    You cannot use the replacepv command on a snapshot volume group or a volume group that has a snapshot volume group.
    Running this command on a physical volume that has an active firmware assisted dump logical volume temporarily changes the dump device to /dev/sysdumpnull. After the migration of logical volume is successful, this command calls the sysdumpdev -P command to set the firmware assisted dump logical volume to the original logical volume.
   The VG corresponding to the SourcePhysicalVolume is examined to determine if a PV type restriction exists. If a restriction exists, the DestinationPhysicalVolume is examined to ensure that it meets the restriction. If it does not meet the PV type restriction, the command will fail.

The allocation of the new physical partitions follows the policies defined for the logical volumes that contain the physical partitions being replaced.

-f Forces to replace a SourcePhysicalVolume with the specified DestinationPhysicalVolume unless the DestinationPhysicalVolume is part of another volume group in the Device Configuration Database or a volume group that is active.
-R dir_name Recovers replacepv if it is interrupted by <ctrl-c>, a system crash, or a loss of quorum. When using the -R flag, you must specify the directory name given during the initial run of replacepv. This flag also allows you to change the DestinationPhysicalVolume.

Some of you may be wondering what took me so long to get on board with replacepv. This functionality has been around awhile now (see here and here). Maybe I heard about it, and forgot. I have done the same type of thing using migratepv or running mirrorvg (though in the latter case requires the extra step of breaking the mirror by removing logical volumes from the disk I wanted to remove).

Going forward though, I’ll be sure to add this to my bag of tricks. I would encourage anyone else who hasn’t used replacepv to do the same.