diff --git a/lvm/CHANGELOG b/lvm/CHANGELOG index d7893a512..b81371d0c 100644 --- a/lvm/CHANGELOG +++ b/lvm/CHANGELOG @@ -26,3 +26,4 @@ When editing a logical volume, the size is shown in GB or TB where possible. ---- Changes since 1.510 ---- Mounted ext3+, reiser, xfs and jfs logical volumes can now have their filesystem size increased, without needing an un-mount. Thanks to Caspar Smit for the suggestions and patches to implement this. When editing a logical volume that is already in /etc/fstab, don't allow the filesystem to format it as to be changed, to prevent a mismatch. +When editing a physical volume, its size can be increased to match the underlying device, such as a partition that has been grown. diff --git a/lvm/edit_pv.cgi b/lvm/edit_pv.cgi index 28c10ffff..d77fc7c5b 100755 --- a/lvm/edit_pv.cgi +++ b/lvm/edit_pv.cgi @@ -70,6 +70,7 @@ else { print &ui_table_end(); if ($in{'pv'}) { print &ui_form_end([ [ undef, $text{'save'} ], + [ 'resize', $text{'pv_resize'} ], @pvs > 1 ? ( [ 'delete', $text{'pv_delete2'} ] ) : ( ) ]); } diff --git a/lvm/lang/en b/lvm/lang/en index fdb15b25d..a7bcbda50 100644 --- a/lvm/lang/en +++ b/lvm/lang/en @@ -135,8 +135,10 @@ pv_pesize=Allocation block size pv_warn=Warning! All data on the selected device will be erased. pv_create2=Add to volume group pv_delete2=Remove from volume group +pv_resize=Resize To Match Device pv_err=Failed to save physical volume pv_err2=Failed to remove physical volume +pv_err3=Failed to resize physical volume pv_delete=Remove Physical Volume pv_rusure=Are you sure you want to remove physical volume device $1 from its volume group? This will result in any data being shifted to other physical volumes within the group. pv_deleteok=Remove Volume @@ -172,6 +174,7 @@ log_mkfs_lv=Created $1 filesystem on $2 log_create_pv=Added physical volume $1 to VG $1 log_modify_pv=Modified physical volume $1 in VG $2 log_delete_pv=Removed physical volume $1 from VG $2 +log_resize_pv=Resized physical volume $1 in VG $2 blocks=blocks diff --git a/lvm/lvm-lib.pl b/lvm/lvm-lib.pl index 3de7ede45..c5aedf941 100755 --- a/lvm/lvm-lib.pl +++ b/lvm/lvm-lib.pl @@ -103,6 +103,7 @@ return @rv; } # create_physical_volume(&pv, [force]) +# Add a new physical volume to a volume group sub create_physical_volume { local $cmd = "pvcreate -y ".($_[1] ? "-ff " : "-f "); @@ -115,6 +116,7 @@ return $? ? $out : undef; } # change_physical_volume(&pv) +# Change the allocation flag for a physical volume sub change_physical_volume { local $cmd = "pvchange -x ".quotemeta($_[0]->{'alloc'}). @@ -124,6 +126,7 @@ return $? ? $out : undef; } # delete_physical_volume(&pv) +# Remove a physical volume from a volume group sub delete_physical_volume { if ($_[0]->{'pe_alloc'}) { @@ -143,6 +146,14 @@ local $out = &backquote_logged("$cmd 2>&1 {'device'}); +local $out = &backquote_logged("$cmd 2>&1"); +return $? ? $out : undef; +} # list_volume_groups() # Returns a list of all volume groups diff --git a/lvm/save_pv.cgi b/lvm/save_pv.cgi index 0e15f5a68..c3733ab7a 100755 --- a/lvm/save_pv.cgi +++ b/lvm/save_pv.cgi @@ -10,7 +10,7 @@ require './lvm-lib.pl'; if ($in{'pv'}); if ($in{'confirm'}) { - # Delete the logical volume + # Delete the physical volume &error_setup($text{'pv_err2'}); $err = &delete_physical_volume($pv); &error("
$err
") if ($err); @@ -30,6 +30,14 @@ elsif ($in{'delete'}) { print "\n"; &ui_print_footer("index.cgi?mode=pvs", $text{'index_return'}); } +elsif ($in{'resize'}) { + # Scale up to match device + &error_setup($text{'pv_err3'}); + $err = &resize_physical_volume($pv); + &error("
$err
") if ($err); + &webmin_log("resize", "pv", $in{'pv'}, $pv); + &redirect("index.cgi?mode=pvs"); + } else { &error_setup($text{'pv_err'}); if (!$in{'pv'}) {