LVM Cheatsheet
LVM Cheatsheet
This is a quick cheat sheet on LVM using AIX, I have highlighted many of the common attributes for
each command however this is not an extensive list, make sure you look up the command.
First a quick review on some of the terminology that AIX LVM uses
Examples
PHYSICAL VOLUME
(PV)
What it means
Represents a hard disk (hdisk0).
PHYSICAL PARTITION The smallest allocation unit in the LVM. All PPs within a VG are the
(PP)
same size, usually 4 or 8 MB.
VOLUME GROUP (VG)
A set of one or more PVs which form a single storage pool. You can
define multiple VGs on each AIX system.
LOGICAL VOLUME
(LV)
One or more PPs. A file system resides on top of an LV. Only one LV is
mapped to a file system. A LV can't span across a VG. Up to 255 LVs in a
VG
LOGICAL PARITITION One or more PPs. LP represents a mirrored copy of a PP. Up to two
(LP)
copies of a PP can be mirrored resulting in a LP count of three (2 mirrors
plus original).
Volume Group Descriptor Information about all the LVs and PVs within a VG. The first 64K of a
Area (VGDA)
PV is reserved for this area - defined in <sys/bootrecord.h>.
The VGDA consists of
BOOTRECORD: - first 512 bytes. Allows the Read Only
System (ROS) to boot system
BAD BLK DIRECTORY - found in <sys/bddir.h>
LVM RECORD - found in <lvmrec.h>
Volume Group Status Area Information about which PPs that are stale and which PVs are missing
(VGSA)
within a VG. The LVM and SCSI driver reserves somewhere between 710% of the available disk space for LVM maps, etc.
Physical Volume ID
(PVID)
Quorum
The logical volume control block (lvcb) consists of the rst 512 bytes of
a logical volume. This area holds important
information such as the creation date of the logical volume, information
about mirrored copies, and possible mount points
in a journaled lesystem.
Logical Volume ID (LVID) The LVID is the soft serial number used to represent the logical volume
to the LVM libraries and low level commands. The
LVID is created from the VGID of the volume group, a decimal point,
and a number which represents the order which the
logical volume was created on the volume group.
Now for the cheet sheet
Directory and Files
Directories and Files
Tools
diag - used to hot swap the disk
cfgmgr - used mak sure the new disk is seen
diagnostic
# to add new disk from the scsi0 controller
cfgmgr -l scsi0
cfgmgr -l scsi0
Create/Remove hard
mkdev -c disk -l <pv>
disk
rmdev -dl <pv>
Physical Volumes
display
lspv
lspv <pv>
lspv -l <pv>
lspv -p <pv>
PVID
(detailed)
(list logical volumes)
(physical partition usage)
removing
chpv -v r <pv>
change physical
attributes
chpv -a y <pv>
chpv -a n <pv>
moving
lsvg
lsvg <vg>
(detailed)
lsvg -l <vg>
(list all logical volumes in goup)
lsvg -p <vg>
(list all physical volumes in group)
lsvg -o
(lists all varied on)
lsvg -M <vg>
(lists assicated disks and state)
display
varyon
varyoffvg <vg>
Note: the varyon command activiates the volume goup which means it is
available for use
## Determine if the ODM and VGDA are correct (in sync)
getlvodm -u <vg>
ODM related
creating
reducing
## removes the PVID from the VGDA when a disk has vanished without
using the reducevg command
reducevg <vg> <PVID>
varyoffvg <vg>
exportvg <vg>
removing
Note: the export command nukes everything regardingthe volume goup in the
ODM and /etc/filesystems
## check to see if underlying disk has grown in size
chvg -g <vg>
checking
change volume
attributes
Note: use this command if you are using SAN LUN's that have increased in
size
## auto vary on a volume at system start
chvg -a y
# Turns on/off quorum checking on a volume group
chvg -Q [y|n] <vg>
renaming
importing
exporting
varyoffvg <vg>
exportvg <vg>
Note: if the volume has an active paging space this must be turned off before
Logical Volumes
display
lslv <lv>
lslv -l <lv>
lslv -m <lv>
extending
reducing/resizing
removing
rmlv <lv>
moving
adding a mirror to a
mklvcopy -s n <lv> <copies 2 or 3> <pv>
non-mirrored volume
rmlvcopy <lv> <copies 1 or 2>
removing a mirror
rmlvcopy <lv> <copies 1 or 2> <pv>
copy from a mirrored
volume
unmirrorvg <vg> <pv>
synchronize logical
volume
syncvg -p <pv>
syncvg -v <vg>
syncvg -l <lv>
mirror any
unmirrored volumes
change volume
attributes
(specified pv)
renaming
Miscellaneous
(detailed)
display
Note: use the '-q' to see if the logical volume size is bigger than the filesystem
size
create
Note: if all filesystems have been removed from a logical volume then the
logical volume is removed as well.
chfs -a size=<new size> <fs>
resize
mount
mount
mount [<fs>|<lv>]
mount -a
mount all
defrag
defragfs -q <fs>
defragfs -r <fs>
defragfs <fs>
checking and
repairing
## Now mirror both the volume group log logical volume and the logical
volume
mklvcopy dataloglv 2
mklvcopy data01lv 2
## Make sure everything is sync'ed both the log and the logical volume
syncvg -v datavg
## Make sure everything is OK
lsvg -l datavg
## a quick way to perform the above in two steps
mklv -c 2 -t jfs2 -y data02lv datavg 8
crfs -v jfs -d data02lv -m /data02 -A yes
## mount everything and check
mount -a
Replaced failed
mirror drive
## configure new disk an check the new number (hopefully the same)
cfgmgr -v
lsdev -Cc <pv>
## add back to volume group
extendvg <vg> <pv>
## create mirror (two ways to do this)
mklvcopy <lv> 2 <pv>
mirrorvg <lv>
## sync mirror
syncvg -l <lv>
## If this is the rootvg there are additonal steps to take
bosboot -ad /dev/<pv>
bootlist -m normal <pv> <pv>
bootlist -m normal -o
## This procedure places back a mirror disk that you have accidently pulled or
that a SAN LUN disappeared off the network
## and its states is classed as "missing"
## see that the disk is in a missing state (see PV state column), also see stale
volumes
lsvg -p <vg>
lsvg -M <vg>
## To make the disk active again we use the varyonvg command
varyonvg <vg>
Accidently remove a
mirrored disk or SAN
LUN disappeared off ## see that the disk is in a active state (see PV state column)
lsvg -p <vg>
the network
## Now re-sync the volumes in that volume group
syncvg -v <vg>
## Make sure that no volumes are stale
lsvg -M <vg>
## Determine if the ODM and VGDA are correct (in sync)
getlvodm -u <vg>