diff options
Diffstat (limited to 'perl-install/lvm.pm')
| -rw-r--r-- | perl-install/lvm.pm | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm index e2eeb4cdc..bace3e3ba 100644 --- a/perl-install/lvm.pm +++ b/perl-install/lvm.pm @@ -1,4 +1,4 @@ -package lvm; # $Id: lvm.pm 268652 2010-05-13 17:09:00Z pterjan $ +package lvm; use diagnostics; use strict; @@ -12,6 +12,16 @@ use devices; use fs::type; use run_program; +=head1 SYNOPSYS + +Manage LVM (PV, VG, LV) + +=head1 Functions + +=over 4 + +=cut + #- for partition_table_xxx emulation sub new { my ($class, $name) = @_; @@ -29,11 +39,23 @@ sub cylinder_size { $hd->{extent_size}; } +=item detect_durting_install() + +Explicitly scan VGs. + +=cut + sub detect_during_install() { run_program::run('lvm2', 'vgscan'); run_program::run('lvm2', 'vgchange', '-a', 'y'); } +=item init() + +Loads LVM modules and scan VGs (if in installer, not in standalone tool). + +=cut + sub init() { devices::init_device_mapper(); detect_during_install() if $::isInstall; @@ -42,6 +64,13 @@ sub init() { init() or log::l("lvm::init failed"); +=item lvm_cmd(...) + +Run a LVM command, then rescan VG. +See run_program::run() for arguments. + +=cut + sub lvm_cmd { if (my $r = run_program::run('lvm2', @_)) { $r; @@ -54,6 +83,13 @@ sub lvm_cmd { run_program::run('lvm2', @_); } } + +=item lvm_cmd_or_die($prog, @para) + +Like lvm_cmd() but die if there's an error. + +=cut + sub lvm_cmd_or_die { my ($prog, @para) = @_; my @err; @@ -112,6 +148,12 @@ sub lv_nb_pvs { listlength(lv_to_pvs($lv)); } +=item get_lvs($lvm) + +Return list of LVs. + +=cut + sub get_lvs { my ($lvm) = @_; my @l = run_program::get_stdout('lvm2', 'lvs', '--noheadings', '--nosuffix', '--units', 's', '-o', 'lv_name', $lvm->{VG_name}) =~ /(\S+)/g; @@ -119,10 +161,13 @@ sub get_lvs { [ map { my $device = "$lvm->{VG_name}/$_"; + my $p = fs::wild_device::to_subpart("/dev/$device"); my $part = { device => $device, lv_name => $_, rootDevice => $lvm->{VG_name}, + minor => $p->{minor}, + major => $p->{major}, size => get_lv_size($device) }; if (my $type = -e "/dev/$device" && fs::type::type_subpart_from_magic($part)) { put_in_hash($part, $type); @@ -238,4 +283,8 @@ sub create_singleton_vg { add_to_VG($part, $lvm); } +=back + +=cut + 1; |
