Button to resize physical volume
authorJamie Cameron <jcameron@webmin.com>
Tue, 29 Jun 2010 20:51:36 +0000 (13:51 -0700)
committerJamie Cameron <jcameron@webmin.com>
Tue, 29 Jun 2010 20:51:36 +0000 (13:51 -0700)
lvm/CHANGELOG
lvm/edit_pv.cgi
lvm/lang/en
lvm/lvm-lib.pl
lvm/save_pv.cgi

index d7893a5..b81371d 100644 (file)
@@ -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.
index 28c10ff..d77fc7c 100755 (executable)
@@ -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'} ] )
                                      : ( ) ]);
        }
index fdb15b2..a7bcbda 100644 (file)
@@ -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
 
index 3de7ede..c5aedf9 100755 (executable)
@@ -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 </dev/null");
 return $? ? $out : undef;
 }
 
+# resize_physical_volume(&pv)
+# Set the size of a physical volume to match the underlying device
+sub resize_physical_volume
+{
+local $cmd = "pvresize ".quotemeta($_[0]->{'device'});
+local $out = &backquote_logged("$cmd 2>&1");
+return $? ? $out : undef;
+}
 
 # list_volume_groups()
 # Returns a list of all volume groups
index 0e15f5a..c3733ab 100755 (executable)
@@ -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("<pre>$err</pre>") if ($err);
@@ -30,6 +30,14 @@ elsif ($in{'delete'}) {
        print "</center>\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("<pre>$err</pre>") if ($err);
+       &webmin_log("resize", "pv", $in{'pv'}, $pv);
+       &redirect("index.cgi?mode=pvs");
+       }
 else {
        &error_setup($text{'pv_err'});
        if (!$in{'pv'}) {