NAME
Linux::LVM - Perl extension for accessing Logical Volume Manager(LVM)
data structures on Linux.
SYNOPSIS
use Linux::LVM;Linux::LVM->units('G');
ABSTRACT
The live data used in the examples is included in the DESCRIPTION areafor your convenience and reference.
DESCRIPTION
units() Get or set the units used to report sizes of LVs, PVs, etc.legal values: hbskmgtpeHBSKMGTPEsee man lvm documentation of --unitsget_volume_group_list() This routine will return an array thatcontains the names of the volume groups.@vgs = get_volume_group_list(); print "@vgs \n";Would yield the following: vg00get_volume_group_information($) This routine will return all ofthe volume group information aboutthe specified volume group.%vg = get_volume_group_information("vg00");foreach(sort keys %vg) {print "$_ = $vg{$_}\n";}Would yield the following:access = read/writeact_pv = 2alloc_pe = 3840alloc_pe_size = 15alloc_pe_size_unit = GBcur_lv = 3cur_pv = 2free_pe = 864free_pe_size = 3.38free_pe_size_unit = GBmax_lv = 256max_lv_size = 255.99max_lv_size_unit = GBmax_pv = 256open_lv = 0pe_size = 4pe_size_unit = MBstatus = available/resizabletotal_pe = 4704uuid = BBq8si-NyRR-9ZNW-3J5e-DoRO-RBHK-ckrszivg_number = 0vg_size = 18.38vg_size_unit = GBvgname = vg00get_logical_volume_information($) This routine will return all of thelogical volume information associatedwith the specified volume group.%lv = get_logical_volume_information("vg00");foreach $lvname (sort keys %lv) {foreach(sort keys %{$lv{$lvname}}) {print "$_ = $lv{$lvname}->{$_}\n";}print "\n";}Would yield the following results:alloc_le = 1024allocation = next freecur_le = 1024device = 58:0lv_number = 1lv_size = 4lv_size_unit = GBname = /dev/vg00/lvol1open_lv = 0read_ahead = 1024status = availablewrite_access = read/writealloc_le = 1280allocation = next freecur_le = 1280device = 58:1lv_number = 2lv_size = 5lv_size_unit = GBname = /dev/vg00/lvol2open_lv = 0read_ahead = 1024status = availablewrite_access = read/writealloc_le = 1536allocation = next freecur_le = 1536device = 58:2lv_number = 3lv_size = 6lv_size_unit = GBname = /dev/vg00/lvol3open_lv = 0read_ahead = 1024status = availablewrite_access = read/writeget_physical_volume_information($) This routine will return all of the informationinformation about the physical volumes assignedto the specified volume group.%pv = get_physical_volume_information("vg00");foreach $pvname (sort keys %pv) {foreach(sort keys %{$pv{$pvname}}) {print "$_ = $pv{$pvname}->{$_}\n";}print "\n";}Would yield the following results:device = /dev/hda3free_pe = 0pv_number = 1status = available / allocatabletotal_pe = 2160device = /dev/hda4free_pe = 864pv_number = 2status = available / allocatabletotal_pe = 2544get_lv_info($) This routine will return all of the information about thespecified logical volume. The information will be returnedin a hash.get_lv_info%lv = get_lv_info("/dev/vg00/lvol1");foreach (sort keys %lv) {print "$_ = $lv{$_} \n";}Would yield the following results:access = read/writealloc_le = 1024allocation = next freeblock_device = 58:0current_le = 1024lv_name = /dev/vg00/lvol1lv_number = 1lv_open = 0read_ahead = 1024size = 4size_unit = GBstatus = availablevg_name = vg00get_pv_info($) This routine will return all of the information about thespecified physical volume. The information will be returnedin a hash.%pv = get_pv_info("/dev/hda3");foreach (sort keys %pv) {print "$_ = $pv{$_} \n";}Would yield the following results:alloc_pe = 2160allocatable = yes (but full)free_pe = 0num_lvols = 2pe_size = 4096pe_size_unit = KBytepv_name = /dev/hda3pv_number = 1sectors = 17703630size = 8.44size_info = NOT usable 4.19 MB [LVM: 136 KB]size_unit = GBstatus = availabletotal_pe = 2160uuid = 2c5ADu-oEdt-ovCe-rqp0-MWpF-I5u1-8XigH4vg_name = vg00Command Output Used In The Above Examples: /sbin/vgdisplay -v--- Volume group ---VG Name vg00VG Access read/writeVG Status available/resizableVG # 0MAX LV 256Cur LV 3Open LV 0MAX LV Size 255.99 GBMax PV 256Cur PV 2Act PV 2VG Size 18.38 GBPE Size 4 MBTotal PE 4704Alloc PE / Size 3840 / 15 GBFree PE / Size 864 / 3.38 GBVG UUID BBq8si-NyRR-9ZNW-3J5e-DoRO-RBHK-ckrszi--- Logical volume ---LV Name /dev/vg00/lvol1VG Name vg00LV Write Access read/writeLV Status availableLV # 1# open 0LV Size 4 GBCurrent LE 1024Allocated LE 1024Allocation next freeRead ahead sectors 1024Block device 58:0--- Logical volume ---LV Name /dev/vg00/lvol2VG Name vg00LV Write Access read/writeLV Status availableLV # 2# open 0LV Size 5 GBCurrent LE 1280Allocated LE 1280Allocation next freeRead ahead sectors 1024Block device 58:1--- Logical volume ---LV Name /dev/vg00/lvol3VG Name vg00LV Write Access read/writeLV Status availableLV # 3# open 0LV Size 6 GBCurrent LE 1536Allocated LE 1536Allocation next freeRead ahead sectors 1024Block device 58:2--- Physical volumes ---PV Name (#) /dev/hda3 (1)PV Status available / allocatableTotal PE / Free PE 2160 / 0PV Name (#) /dev/hda4 (2)PV Status available / allocatableTotal PE / Free PE 2544 / 864
SEE ALSO
vgdisplay(1M) lvdisplay(1M) pvdisplay(1M)
AUTHOR
Chad Kerner, <[email protected]>
COPYRIGHT AND LICENSE
Copyright 2003 by Chad Kerner
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.