Inhaltsverzeichnis
Logical Volume Manager (LVM) Commands for AIX
Command Summary
First a quick review on some of the terminology that AIX LVM usesShort | Definition | Description |
---|---|---|
PV | PHYSICAL VOLUME | |
Command | Definition |
---|---|
Physical Volumes related |
|
lspv [-l] [-M|p-] [-L] PV | Lists the disks on the server, including the physical volume will give details about that disk. -l option will list the details of how the filesystems are distributed on the disk. -M | -p option lists logical volumes details on physical disk. -L displays the physical volume characteristics. |
chdev -l PV -a pv=yes | assign a PVID to a new hdisk (PV) |
lsvpcfg | Lists each vpath and the hdisks that make up the vpath |
Logical Volume related |
|
lslv [-l|-m] [-L] LV | Lists information about the logical volumes. -l | -m option lists disks in the logical volume. -L displays the logical volume characteristics. |
chlv -n newname oldname | Change the name of a logical volume (it must be inactive) |
mklv -y LV_name VG | Makes a logical volume in a volume group |
rmlv LV | Removes a logical volume (it must be inactive) |
Volume Group related |
|
lsvg [-l] [-L] [-p] VG | Lists the volume groups on the server, including the volume group name will give details about that vg. -l option list the logical volumes in the volume group. -L displays the logical volume characteristics. -p option lists disks in the volume group |
mkvg -y VG PV . . . PV | Makes a volume group out of one or more physical volumes |
varyonvg VG | take the VG online |
varyoffvg VG | take the VG offline |
exportvg VG | removes a volume group from a machine |
extendvg VG PV ... PV | Adds a new physical volume to an existing volume group |
importvg -y VG PV | add a volume group to another machine |
savevg -l -f device VG | makes a backup copy of another volume group |
reducevg VG PV ... PV | Removes a physical volume from a volume group |
Filesystem related |
|
df -k | Shows the disk usage of logical volumes on the server. |
df -Pm | Shows the disk usage of logical volumes in portability modus and size in MB |
crfs -v jfs -m filesystem -g VG -a logname=LV_Name -a size="# of 512 byte blocks" | This command makes a logical volume LVName, with size=#, mount point with a journaled file system |
crfs -v jfs2 -A yes -p rw -d LV -m MP -a logname=INLINE | creates a read write jfs2 file system on a logical volume LV and for Mount Point MP and logging on the same LV |
crfs -v jfs2 -m filesystem -d LV | creates a jfs2 file system on a logical volume |
chfs -a size="#512 byte blocks" filesystem | Increases the size of a journaled file system to the total number of 512 byte blocks specified |
chfs -a size="+512 byte blocks" filesystem | Increases the size of a journaled file system by the addional number of 512 byte blocks specified. Beispiel:chfs -a size=+393216 /usr |
rmfs filesystem | removes a file system and it's logical volume |
mount LV filesystem | mount logical volume on files system mount point |
mount filesystem | mount filesystem if it is already in /etc/filesystems |
umount filesystem | unmount the file system |
Filesystem backup |
|
mksysb -l -f device | makes a bootable backup of rootvg |
Glossary
Term | Definition |
---|---|
Journaled File System (JFS) | File system that uses a journaled log for faster, more reliable data recovery |
Logical Partition (LP) | The LV is made up of LPs. The LP corresponds to 1 or more (in the case of mirroring) PPs. |
Logical Volume (LV) | The VG is subdivided into logical volumes and each LV can have a file system on it. |
Physical Partition (PP) | All physical volumes are subdivided into pps. PPs are all the same size. |
Physical Volume (PV) | Disk that is being managed by LVM. |
rootvg | Default volume group created during installation. The vg holds the OS filesystems ( /,/usr, /home, /proc /opt, /tmp, /var and swap space ) |
Volume Group (VG) | Area of storage that consists of one or more PVs |
Sample LVM Procedures:
move Logical Volume to new assigned disks and remove old disk
Some people always like to use mirroring. Others always use migratepv, because it seems a lot easier, as the data can be moved in a single command. But there are advantages for using the mirroring option with mklvcopy.mklvcopy lets you create the copy without having to synchronize the data straight away. That means you can synchronize the copies later on using syncvg, perhaps when I/O activity isn’t so intense. The syncvg command allows you to synchronize Physical Partitions (PPs) in parallel using the -P flag or by setting the NUM_PARALLEL_LPS environment variable. Neither migratepv nor mklvcopy allow this.
You can also monitor progress of your synchronization by checking the stale partition count with lsvg or lspv. In contrast, if you try to check how migratepv is going, you'll get a message saying there's a lock on the volume group.
Another benefit of using mklvcopy is you can keep two current copies of your data before you commit to using the target PV. Although this doubles the writes while both copies are in use, you can easily remove the copy from the source PV later or from the target if you want to revert to the source PV quickly.
If you did't synchronize the LV, rmlvcopy gives an error, when you try to remove the last good copy while there are still some stale partitions.
direct migration from old to new disk (migratepv)
The migratepv command is the easiest way of moving data. You can migrate a logical volume to one or more PVs with one command. As a minimum, you need a source PV and a target PV, and both of them must be in the same volume group.- add new disk to VG
extendvg [VG] [hdisk##]
- migrate whole disk
migratepv -l lv02 hdisk_old hdisk_new1 ... hdisk_new#
- or migrate one logical volume after another
migratepv -l lv02 hdisk_old hdisk_new1 ... hdisk_new#
- The above command will move all of the physical partitions. The command may take a while to complete. That's because it creates a mirror of the data, synchronizes the copy and then removes the original. If the command is successful, the old disk will have 0 physical partitions in use, but still remain in the volume group.You can remove it from the volume group using reducevg.
reducevg [Volume Group] [physical Volume]
migratelp httplv/63/2 hdisk27/100
use additonal mirror for the migration (mklvcopy)
If, instead of moving data in one hit, create a mirror of each LV using the mklvcopy command. You can synchronize the two copies when you run the mklvcopy command with option -k , or do it afterward. It makes sense to create the mirror copy without synchronizing immediately. This allows you to arrange the synchronization of the copy to run at a quiet time.- add new disk to VG
extendvg [VG] [hdisk##]
- mirror Logical Volume. With mklvcopy, you need to indicate how many copies of the LV you want to end up with. You can have two or three copies.
mklvcopy -s y [Logical Volume] [Number of mirrors 2|3] [physical Volume]
- synchronize Volume Group
syncvg -v [Volume Group]
- or synchronize Physical Volumes at a quiet time when I/O activity isn’t so intense.
syncvg -p [Physical Volume(s)]
- verify successful mirroring (pps will appear "stale" until synchronization is complete).
lsvg -l [Volume Group]
- remove mirror on old disk
rmlvcopy [Logical Volume] 1 [OLD physical Volume]
- the old disk can be removed from the Volume Group, if all Logical Volumes are moved to the new disk
reducevg [Volume Group] [physical Volume]
Mirror rootvg
Make sure you have an empty disk, in this example its hdisk1Add the disk to the rootvg
extendvg rootvg hdisk1
Mirror the rootvg via
mirrorvg rootvg
Adapt the bootlist to add the current disk, the system will then fail to hdisk1 is hdisk0 fails during startup
bootlist -o -m normal
this will list currently 1 disk, in this exmaple hdisk0, run command below to add the second disk
bootlist -m normal hdisk0 hdisk1
Run a bosboot on both new disks, this will install all software needed for boot on the disk
bosboot -ad hdisk0 bosboot -ad hdisk1