From 0fee21cdb0c5aedaabe34a0a3067fe8a92a958bc Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 21 Nov 2008 05:48:48 +0000 Subject: [PATCH] Allow EXT shrinking with resize2fs --- lvm/CHANGELOG | 1 + lvm/lvm-lib.pl | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lvm/CHANGELOG b/lvm/CHANGELOG index 3bb5eddce..28551adce 100644 --- a/lvm/CHANGELOG +++ b/lvm/CHANGELOG @@ -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. diff --git a/lvm/lvm-lib.pl b/lvm/lvm-lib.pl index e3a4eddbd..39c66cc47 100644 --- a/lvm/lvm-lib.pl +++ b/lvm/lvm-lib.pl @@ -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; } } }