Allow EXT shrinking with resize2fs

This commit is contained in:
Jamie Cameron
2008-11-21 05:48:48 +00:00
parent 3a6da57c71
commit 0fee21cdb0
2 changed files with 5 additions and 4 deletions

View 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.

View 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;
}
}
}