summaryrefslogtreecommitdiffstats
path: root/perl-install/lvm.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-09-05 15:32:07 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-09-05 15:32:07 +0000
commit1692731ed6a36367063b2e244728dc725cf85589 (patch)
tree6925d56cafffb421e6b347e03ff20657be526dc3 /perl-install/lvm.pm
parent8e8ee798295c4147330a1fbd907d6214c7be5716 (diff)
downloaddrakx-backup-do-not-use-1692731ed6a36367063b2e244728dc725cf85589.tar
drakx-backup-do-not-use-1692731ed6a36367063b2e244728dc725cf85589.tar.gz
drakx-backup-do-not-use-1692731ed6a36367063b2e244728dc725cf85589.tar.bz2
drakx-backup-do-not-use-1692731ed6a36367063b2e244728dc725cf85589.tar.xz
drakx-backup-do-not-use-1692731ed6a36367063b2e244728dc725cf85589.zip
fix using given size for created LVs whereas lvcreate allocates a little less
(thanks to Alan Hughes)
Diffstat (limited to 'perl-install/lvm.pm')
-rw-r--r--perl-install/lvm.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm
index 01e8e55a6..c5a336d22 100644
--- a/perl-install/lvm.pm
+++ b/perl-install/lvm.pm
@@ -68,6 +68,12 @@ sub update_size {
$lvm->{totalsectors} = ($lvm->{PE_size} = $l[12]) * $l[13];
}
+sub get_lv_size {
+ my ($lvm_device) = @_;
+ my $info = run_program::get_stdout('lvdisplay', '-D', '-c', "/dev/$lvm_device");
+ (split(':', $info))[6];
+}
+
sub get_lvs {
my ($lvm) = @_;
my @l = run_program::get_stdout('vgdisplay', '-v', '-D', $lvm->{VG_name});
@@ -75,11 +81,10 @@ sub get_lvs {
[
map {
my $type = -e "/dev/$_" && fsedit::typeOfPart("/dev/$_");
- my $info = run_program::get_stdout('lvdisplay', '-D', '-c', "/dev/$_");
{ device => $_,
type => $type || 0x83,
- size => (split(':', $info))[6] }
+ size => get_lv_size($_) }
} map { if_(m|^LV Name\s+/dev/(\S+)|, $1) } @l
];
}
@@ -120,6 +125,7 @@ sub lv_create {
my $nb = 1 + max(map { basename($_->{device}) } @$list);
$lv->{device} = "$lvm->{VG_name}/$nb";
run_or_die('lvcreate', '--size', int($lv->{size} / 2) . 'k', '-n', $nb, $lvm->{VG_name});
+ $lv->{size} = get_lv_size($lv->{device}); #- the created size is smaller than asked size
$lv->{notFormatted} = 1;
$lv->{isFormatted} = 0;
push @$list, $lv;
@@ -129,6 +135,7 @@ sub lv_resize {
my ($lv, $oldsize) = @_;
run_or_die($oldsize > $lv->{size} ? ('lvreduce', '-f') : 'lvextend',
'--size', int($lv->{size} / 2) . 'k', "/dev/$lv->{device}");
+ $lv->{size} = get_lv_size($lv->{device}); #- the resized partition may not be the exact asked size
}
1;