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
0516-404 allocpThis system cannot fulfill the allocation
Viewed 9851 times since Thu, Sep 20, 2018
AIX 6.1: Extend VG 0516-1714 extendvg 0516-1254 extendvg
Viewed 4327 times since Fri, Jul 6, 2018
bootlist multiple boot logical volume found
Viewed 2565 times since Tue, Apr 16, 2019
AIX Different Commands For Paging Space Administration swap file create
Viewed 7172 times since Thu, Aug 1, 2019
How to Configure Sendmail not to Look up MX records
Viewed 3352 times since Fri, Apr 19, 2019
AIX oslevel version OS
Viewed 4647 times since Wed, Apr 17, 2019
Altering LVM Configuration When a Disk is Not in ODM Anymore
Viewed 2806 times since Mon, Jun 3, 2019
Part 3, Monitoring your network packets and tuning the network
Viewed 5817 times since Mon, Jun 4, 2018
Using expect to automate mundane tasks
Viewed 1680 times since Mon, Jun 3, 2019
What is OS Watcher Utility and How to use it for Database Troubleshooting ?
Viewed 29601 times since Thu, Jun 21, 2018