LVM is a Logical Volume Manager for AIX. There are a few very useful commands which can help you find a way around AIX's LVM.
If you are going to use smitty (or smit) to manage your system, then you do not need to view the sections below. smitty is self explanatory and does the same commands you see below, when you submit an action
Here's a list of some which will be covered below with a small example for each one:
- 1 Adding a PVID (chdev)
- 2 Remove a PVID from a disk
- 3 List all PVs in a system with VG membership
- 4 Create a VG called datavg using hdisk1 by using 64 Meg PPs
- 5 Create a LV on datavg that is 1 Gig in size
- 6 List all LVs on the datavg VG
- 7 List all PVs in the datavg VG
- 8 Take the datavg VG offline
- 9 Remove the datavg VG from the ODM
- 10 Import the VG which hdisk5 was member of
- 11 Vary-on the new datavg VG
- 12 List all VGs (known to the ODM)
- 13 List all VGs that are on line
- 14 Check to see if underlying disk in datavg has grown in size
- 15 Move a LV from one PV to another
- 16 Delete a VG by removing all PVs with the reducevg command.
- 17 Create a mirror inside a whole VG
Adding a PVID (chdev)
chdev -l <hdisk name> -a pv=yes
chdev -l hdisk0 -a pv=yes
PVID is added automatically to a hdisk when it is added to a VG but there are cases where you would want to add a PVID on your own. For example, if you have an HACMP cluster then adding a disk to a concurrent VG can produce unexpected results unless the disks already have the VG set manually. What would happen is that one node of a cluster would have one PVID and another node a different one, which can cause a cluster VG to go down. In this case the best way to proceed is to manually add a PVID, making sure by comparing that the disks have the same PVID assigned to them (which will happen as soon as you add a PVID on a second node, because it will read it off of the hdisk - if it exists, and will not generate a new one).
Remove a PVID from a disk
chdev -l hdisk1 -a pv=clear
List all PVs in a system with VG membership
Create a VG called datavg using hdisk1 by using 64 Meg PPs
mkvg -y datavg -s 64 hdisk1
Create a LV on datavg that is 1 Gig in size
mklv -t jfs2 -y datalv datavg 16
List all LVs on the datavg VG
lsvg -l datavg
List all PVs in the datavg VG
lsvg -p datavg
Take the datavg VG offline
Remove the datavg VG from the ODM
Import the VG which hdisk5 was member of
The following command will import the VG and name it datavg, alongside it, by reading the VGDA, it will bring all the disks previously belonging to the same VG inside the newly imported VG.
importvg -y datavg hdisk5(-y option specifies the name of the VG you want to put the disk(s) to, in this case it will be datavg)
Vary-on the new datavg VG
(can use importvg -n to bring it immediately online)
List all VGs (known to the ODM)
List all VGs that are on line
Check to see if underlying disk in datavg has grown in size
chvg -g datavg
- The user might be required to execute varyoffvg and then varyonvg on the volume group for LVM to see the size change on the disks. - There is no support for re-sizing while the volume group is activated in classic or enhanced concurrent mode. - There is no support for re-sizing for the rootvg.
Move a LV from one PV to another
migratepv -l datalv01 hdisk4 hdisk5
Delete a VG by removing all PVs with the reducevg command.
reducevg hdisk3(-d removes any LVs that may be on that PV)
Create a mirror inside a whole VG
When you have a VG to which you add new disks, you can make AIX create a mirror of the currently running disks to the new ones. There are a few ways to do this. If you would like to make an exact physical partition copy (create copies of LVs in exact physical partition order) you can use the command:
mirrorvg -c 2 -m <list of disks>
Be aware that in this case the newly added disks have to be the same size as the already existing VG disks, they need to have enough free space to perform a mirror and no other LV in the VG being mirrored can have a mirror already. If one of the previous statements is true - the command will fail. You can do a mirrorvg without the -m option, in which case it doesn't matter which are the disk sizes, since the AIX will distribute the PP mirroring across all the disks in the VG "randomly".