Allow EXT shrinking with resize2fs
authorJamie Cameron <jcameron@webmin.com>
Fri, 21 Nov 2008 05:48:48 +0000 (05:48 +0000)
committerJamie Cameron <jcameron@webmin.com>
Fri, 21 Nov 2008 05:48:48 +0000 (05:48 +0000)
lvm/CHANGELOG
lvm/lvm-lib.pl

index 3bb5edd..28551ad 100644 (file)
@@ -14,3 +14,4 @@ Fixed the command used to move data to another physical volume under LVM 2.
 The percentage of a snapshot's blocks used is now shown on the Edit Snapshot page.
 ---- Changes since 1.440 ----
 Filesystem space used is show on the logical volume list, and the field for a new volume's size is more user-friendly.
+When using newer versions of the resize2fs command, EXT filesystems can be shrunk as well as enlarged.
index e3a4edd..39c66cc 100644 (file)
@@ -421,8 +421,8 @@ if ($_[0] eq "ext2" || $_[0] eq "ext3") {
                }
        elsif (&has_command("resize2fs")) {
                # Only new versions can reduce a FS
-               local $out = &backquote_command("resize2fs");
-               return $out =~ /resize2fs\s+([0-9\.]+)/i && $1 > 1.4 ? 2 : 1;
+               local $out = &backquote_command("resize2fs 2>&1");
+               return $out =~ /resize2fs\s+([0-9\.]+)/i && $1 >= 1.4 ? 2 : 1;
                }
        else {
                return 0;
@@ -476,10 +476,10 @@ if ($_[1] eq "ext2" || $_[1] eq "ext3") {
                        # Need to shrink filesystem first, then LV
                        local $cmd = "resize2fs -f '$_[0]->{'device'}' $_[2]k";
                        local $out = &backquote_logged("$cmd 2>&1");
-                       return $? ? $out : undef;
+                       return $out if ($?);
 
                        local $err = &resize_logical_volume($_[0], $_[2]);
-                       return $err if ($err);
+                       return $err;
                        }
                }
        }