Remove disk from volumegroup in AIX

Sometimes in a migration project you need to temporary add extra disks to volume group. As a storage admin you like get 
the disks back when your colleagues are finished migrating the application. I tried to create a clear procedure to get this done.

Used commands:
- df
- lspv
- chfs
- cfgmgr
- vgextend
- migratepv
- reducevg
- rmdev


 
In this example we have a "vgexports" volumegroup which is 2TB and you only use 17%. You like to reduce the size to 600GB. First 
you need to create the new disks on your storage system and map the host to the volumes. We create 3 disks of 200GB to create the 
wanted 600GB. It is best practice to create multiple physical volumes in a volume group to be more flexible with in- and decreasing 
a volume group.

root@lpar001:~\:>df -g |grep exports
Filesystem         GB blocks  Free      %Used   Iused   %Iused  Mounted on
/dev/exportsfs     2000.00    1660.30   17%     2730    1%      /exports

In this case we have 2 disks of 1TB in this volume group.

root@lpar001:~\:>lspv |grep vgexports
hdisk0          00f90383de4344a5                    vgexports       active
hdisk1          00f90383e758cfcb                    vgexports       active

We want to remove these disks and replace them for 3 200GB disks to reduce the filesystem with 1.4TB.

First we kan reduce the filesystemsize to 600GB with the command chfs. This can take a while, depending on the size of the filesystem.

root@lpar001:~\:>chfs -a size=600G /dev/exportsfs
Filesystem size changed to 1258291200

root@lpar001:~\:>df -g |grep exports
Filesystem          GB blocks Free     %Used   Iused    %Iused  Mounted on
/dev/exportsfs      600.00    260.51   57%     2730     1%      /exports

Before we can remove the disks, we need to add additional smaller disks to which which we can migrate the partitions to. After you created and mapped the physical disks to this lpar from your storage device, you have to detect them with the cfgmgr command.

root@lpar001:~\:>cfgmgr
(no output)

If the disks are recognized, you should "see" them with the lspv command.

root@lpdd002:~\:>lspv
hdisk0          00f90383cdb8533f                    rootvg          active
hdisk1          00f90383de4344a5                    vgexports       active
hdisk2          00f90383e758cfcb                    vgexports       active
hdisk3          none                                None
hdisk4          none                                None
hdisk5          none                                None

The 3 new disks are shown with volumegroup "None". Now you have to add them to the volumegroup "vgexports". You can add them to the vgexports with the extendvg command.

extendvg vgexports hdisk3 hdisk4 hdisk5

After this the lspv shows this output.

root@lpar001:~\:>lspv | grep export
hdisk0          00f90383cdb8533f                    rootvg          active
hdisk1          00f90383de4344a5                    vgexports       active
hdisk2          00f90383e758cfcb                    vgexports       active
hdisk3          00fad72c95e94950                    vgexports       active
hdisk4          00fad72c95e976a5                    vgexports       active
hdisk5          00fad72c95e981ce                    vgexports       active
 
So hdisk1 and hdisk2 are the 1TB disks and hdisk3, hdisk4 and hdisk5 are the 200GB disks. 

Now we can empty the 1TB disks, which we like to remove from the volumegroup, with the command migratepv. This can take a while, depending on the size of the partitions.

root@lpar001:~\:>migratepv hdisk1 hdisk2 
(no output)

After migration of the partitions, you should be able to remove the disks from the volume group with the reducevg command.

root@lpar001:~\:>reducevg vgexports hdisk1
root@lpar001:~\:>lspv
hdisk0          00f90383cdb8533f                    rootvg          active
hdisk1          00f90383de4344a5                    None
hdisk2          00f90383e758cfcb                    vgexports       active
hdisk3          00fad72c95e94950                    vgexports       active
hdisk4          00fad72c95e976a5                    vgexports       active
hdisk5          00fad72c95e981ce                    vgexports       active

Note. If you try to remove a disk which still has partitions after the migratepv procedure, you will receive an error message.

root@lpar001:~\:>reducevg vgexports hdisk2
0516-016 ldeletepv: Cannot delete physical volume with allocated
        partitions. Use either migratepv to move the partitions or
        reducevg with the -d option to delete the partitions.
0516-884 reducevg: Unable to remove physical volume hdisk3.

In this case you need to decrease the filesystem size again (a few GB should be enough).
after decreasing the filesystem, you need to use the migratepv command (migratepv hdisk2) again on this disk to migrate the leftover partition from this disk. When this is finished you will be able to use reducevg (reducevg vgexports hdisk2) to remove the last harddisk from the volume group.

If both disks are removed from the volume group, you can remove the disks from the OS with the rmdev command.

root@lpar001:~\:>rmdev -dRl hdisk1
hdisk1 deleted

root@lpar001:~\:>rmdev -dRl hdisk2
hdisk2 deleted

If the disks are removed from the OS, you can remove the disks from the storage device and you're done.
5 (1)
Article Rating (1 Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
http://ibmsystemsmag.com/aix/administrator/backuprecovery/remote-sync/
Viewed 5168 times since Wed, May 30, 2018
AIX, Security, System Admin↑ Clearing password history
Viewed 1953 times since Fri, Apr 19, 2019
AIX, Security, System Admin↑ Generating random passwords
Viewed 2757 times since Fri, Apr 19, 2019
Manually Editing /etc/filesystems Can Cause Issues
Viewed 5053 times since Tue, May 22, 2018
AIX: How to manage network tuning parameters
Viewed 3382 times since Mon, Jun 11, 2018
AIX Replacing a failed disk (rootvg)
Viewed 8136 times since Tue, Jul 17, 2018
AIX - How to monitor CPU usage
Viewed 25568 times since Fri, Jun 8, 2018
Tunneling With SSH to Your Destination
Viewed 3878 times since Wed, May 30, 2018
Oslevel shows wrong AIX’s level. Why
Viewed 4477 times since Thu, Feb 21, 2019
AIX lspath Missing path
Viewed 9062 times since Fri, Oct 5, 2018