Scripting importvg on AIX
brian_s 270002K5X3 Comment (1) Visits (14005)
There are some situations where you need to exportvg volume groups, and then reimport them. This often occurs when doing disk migrations between servers. The usual routine is to record which PVID's go with which volume groups, and when you need to import the volume groups again run an importvg and specify the correct volume group name with the hdisk that has the matching PVID. You generally can't rely on the hdisk name/number because it might be numbered differently.
To make this easier, I wrote a small script that automates this process. You run this script before you have exported the volume groups. The script generates the commands you need to run at some point in the future to importvg the volume groups.
Or, if you would prefer a one-liner that you can just copy and paste easily, here is the same script as a one-liner:
On my example server the output of lspv looks like:
When you run the script it generates the commands lines you would need to run in the future to reimport the 3 volume groups:
I can now exportvg these 3 volume groups, and whenever I am ready to importvg them just copy and paste the commands the script generated above. These commands loop through all of the hdisks looking for the correct PVID to match the volume group, and when it finds it runs the importvg command to import the volume group.