diff options
author | Mystery Man <unknown@mandriva.org> | 2002-07-08 07:45:08 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2002-07-08 07:45:08 +0000 |
commit | be128d0615965c467107adeb2c8cecd1125318a1 (patch) | |
tree | 998f5b6803ad85a1411491ef4c499fa8b9760bb2 /perl-install/lvm.pm | |
parent | 9555bb791920e8feace953f90cf908e864451b59 (diff) | |
download | drakx-be128d0615965c467107adeb2c8cecd1125318a1.tar drakx-be128d0615965c467107adeb2c8cecd1125318a1.tar.gz drakx-be128d0615965c467107adeb2c8cecd1125318a1.tar.bz2 drakx-be128d0615965c467107adeb2c8cecd1125318a1.tar.xz drakx-be128d0615965c467107adeb2c8cecd1125318a1.zip |
This commit was manufactured by cvs2svn to create tag 'V1_1_8_2mdk'.V1_1_8_2mdk
Diffstat (limited to 'perl-install/lvm.pm')
-rw-r--r-- | perl-install/lvm.pm | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm deleted file mode 100644 index 327e07fe2..000000000 --- a/perl-install/lvm.pm +++ /dev/null @@ -1,124 +0,0 @@ -package lvm; # $Id$ - -use diagnostics; -use strict; - -#-###################################################################################### -#- misc imports -#-###################################################################################### -use common; -use modules; -use fsedit; -use devices; -use run_program; - -#- for partition_table_xxx emulation -sub hasExtended { 0 } -sub adjustStart {} -sub adjustEnd {} -sub write {} -sub cylinder_size { - my ($hd) = @_; - $hd->{PE_size}; -} - -init(); - -sub init { - eval { modules::load('lvm-mod') }; - run_program::run('vgscan') if !-e '/etc/lvmtab'; - run_program::run('vgchange', '-a', 'y'); -} - -sub check { - my ($in) = @_; - - my $f = '/sbin/pvcreate'; - -e $f or $in->do_pkgs->install('lvm'); - -e $f or $in->ask_warn('', "Mandatory package lvm is missing"), return; - init(); - 1; -} - -sub get_vg { - my ($part) = @_; - my $dev = expand_symlinks(devices::make($part->{device})); - install_any::check_prog ("pvdisplay") if $::isInstall; - (split(':', `pvdisplay -c $dev`))[1]; -} - -sub update_size { - my ($lvm) = @_; - install_any::check_prog ("vgdisplay") if $::isInstall; - my @l = split(':', `vgdisplay -c -D $lvm->{LVMname}`); - $lvm->{totalsectors} = ($lvm->{PE_size} = $l[12]) * $l[13]; -} - -sub get_lvs { - my ($lvm) = @_; - install_any::check_prog ("vgdisplay") if $::isInstall; - my @l = `vgdisplay -v -D $lvm->{LVMname}`; - install_any::check_prog ("lvdisplay") if $::isInstall; - $lvm->{primary}{normal} = - [ - map { - my $type = -e "/dev/$_" && fsedit::typeOfPart("/dev/$_"); - { device => $_, - type => $type || 0x83, - size => (split(':', `lvdisplay -D -c /dev/$_`))[6] } - } map { m|^LV Name\s+/dev/(\S+)| ? $1 : () } @l - ]; -} - -sub vg_add { - my ($part) = @_; - if (my $old_name = get_vg($part)) { - run_program::run('vgchange', '-a', 'n', $old_name); - run_program::run('vgremove', $old_name); - } - my $dev = expand_symlinks(devices::make($part->{device})); - run_program::run_or_die('pvcreate', '-y', '-ff', $dev); - my $prog = run_program::run('vgdisplay', $part->{lvm}) ? 'vgextend' : 'vgcreate'; - run_program::run_or_die($prog, $part->{lvm}, $dev); -} - -sub vg_destroy { - my ($lvm) = @_; - - is_empty_array_ref($lvm->{primary}{normal}) or die _("Remove the logical volumes first\n"); - run_program::run('vgchange', '-a', 'n', $lvm->{LVMname}); - run_program::run_or_die('vgremove', $lvm->{LVMname}); - foreach (@{$lvm->{disks}}) { - delete $_->{lvm}; - $_->{isFormatted} = 0; - $_->{notFormatted} = 1; - } -} - -sub lv_delete { - my ($lvm, $lv) = @_; - - run_program::run_or_die('lvremove', '-f', "/dev/$lv->{device}"); - - my $list = $lvm->{primary}{normal}; - @$list = grep { $_ != $lv } @$list; -} - -sub lv_create { - my ($lvm, $lv) = @_; - my $list = $lvm->{primary}{normal}; - my $nb = 1 + max(map { basename($_->{device}) } @$list); - $lv->{device} = "$lvm->{LVMname}/$nb"; - run_program::run_or_die('lvcreate', '--size', int($lv->{size} / 2) . 'k', '-n', $nb, $lvm->{LVMname}); - $lv->{notFormatted} = 1; - $lv->{isFormatted} = 0; - push @$list, $lv; -} - -sub lv_resize { - my ($lv, $oldsize) = @_; - run_program::run_or_die($oldsize > $lv->{size} ? ('lvreduce', '-f') : 'lvextend', - '--size', int($lv->{size} / 2) . 'k', "/dev/$lv->{device}"); -} - -1; |