This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours

Bug 249645

Summary: RFE- a resize2fs --minimal query option would be nice
Product: [Fedora] Fedora Reporter: Jane Dogalt <jdogalt>
Component: e2fsprogsAssignee: Josef Bacik <jbacik>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: esandeen, katzj
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-02-25 12:08:23 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 235705    

Description Jane Dogalt 2007-07-25 21:08:32 EDT
Description of problem:

jkatz requested I file this bug.  It would be nice if resize2fs would have a
--minimal feature or if there was some way to discover (other than brute force
retrying of various sizes) what the minimal size is that you can resize an
ext2/3 filesystem to.

This would clean up some code in cleanupDeleted in livecd-creator

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Eric Sandeen 2007-09-18 15:13:18 EDT
I'll look into this - one thing that might help in the meantime, is a debug flag
available now, which tells you how much space would be needed:

[root@inode e2fsprogs-1.39]# resize2fs -d 2 fsfile 1024
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on fsfile to 1024 (1k) blocks.
Number of free blocks: 847/4294965071, Needed: 2225  <<---- Need 2225 more
Going into desperation mode for block allocations
resize2fs: No space left on device while trying to resize fsfile

[root@inode e2fsprogs-1.39]# bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
1024+2225  <---- what we asked for + what was needed
3249 <--- so, this is our minimum size
quit

[root@inode e2fsprogs-1.39]# resize2fs -d 2 fsfile 3249
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on fsfile to 3249 (1k) blocks.
Number of free blocks: 847/0, Needed: 0
The filesystem on fsfile is now 3249 blocks long.

and we can't go smaller:

[root@inode e2fsprogs-1.39]# resize2fs -d 2 fsfile 3248
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on fsfile to 3248 (1k) blocks.
Number of free blocks: 0/4294967295, Needed: 1
Going into desperation mode for block allocations
resize2fs: No space left on device while trying to resize fsfile

Comment 2 Jane Dogalt 2007-09-19 01:16:27 EDT
FWIW, before I filed this, I had looked at the resize2fs code, to see if there
was something obvious.  The thing that dissuaded me, was that I found several
independent places where it would jump to the failure-too-small case, for
seemingly completely different reasons.  So I'm not sure if the single heuristic
you describe is a complete solution.
Comment 3 Eric Sandeen 2007-09-19 08:46:54 EDT
You might be right... out of curiosity, what heuristic do you use now, i.e. what
do you use as a starting point (currently used block count?) and how do you see
it fail (by how many blocks)?  I have a patch I'm playing with, but haven't
pointed it at a large variety of populated filesystems yet.

-Eric
Comment 4 Jane Dogalt 2007-09-20 03:42:25 EDT
Currently with livecd-creator there is no heuristic.  Just a low bar of 0, a
high bar of the current size, and then a binary search, simply using success or
failure of the command as the metric to reset one of the bars, until they converge.

There is certainly room to improve that.  Would speed up the livecd creation
process by a small, but significant amount.

Comment 5 Eric Sandeen 2007-09-20 08:41:44 EDT
It'd be interesting to know how the final size usually compares to the
originally reported free blocks, I guess - just out of curiosity... but I
digress... :)
Comment 6 Jeremy Katz 2007-11-26 17:52:50 EST
Changing the summary slightly to reflect that just having a way to be told the
minimum would be nice as opposed to the option to determine and resize to the
minimum.  While both have their uses, the former can trivially be used to pass
to the latter.  And the former is helpful for showing the minimum filesystem
size in, eg, anaconda as well as the resizing in livecd-creator.
Comment 7 Josef Bacik 2008-01-07 15:52:18 EST
sent patch upstream

http://article.gmane.org/gmane.comp.file-systems.ext4/4397

if you specify a resize size of 0 or < than the minimum resize size e2fsprogs will spit out 
the minimum number of blocks needed for a resize.
Comment 8 Jeremy Katz 2008-01-08 12:08:05 EST
Does it require that you go through a fsck of the filesystem first?  If so, it's
going to be a little bit less than ideal for the purposes of finding the minimum
size a filesystem can be resized to for anaconda.  Since we really would prefer
not to make any changes to the filesystem unless the user explicitly requests
doing so
Comment 9 Josef Bacik 2008-01-08 13:11:06 EST
you can specify -f if you want to skip the fsck check.  Upstream doesn't want this feature 
to be its own option, instead opting to have it spit out the correctly calculated minimum 
number of blocks needed in cases where the resize size is too small, so this code is in the 
actual resize code, which means I can't short circuit the fsck check.
Comment 10 Jeremy Katz 2008-01-08 14:03:17 EST
Okie doke -- I'll give it a try as soon as I can to see how it works.  With
school stuff, it might be a couple of weeks until I get a chance, though
Comment 11 Jesse Keating 2008-03-31 13:54:45 EDT
We're pretty late in the F9 cycle for this change, moving to 10.
Comment 12 Jeremy Katz 2008-03-31 14:56:07 EDT
Actually, switching back to F9Target.  Without it, we can't really give users a
good idea of the minimum they can resize to in the installer.  And I think
esandeen said it's upstream
Comment 13 Jon Stanley 2008-04-23 16:28:53 EDT
Adding FutureFeature keyword to RFE's.
Comment 14 Eric Sandeen 2008-11-02 15:59:01 EST
I think this is done, right?  Can we close this as CURRENTRELEASE?

commit 199ddaaa445e14fca8113b0db85e2576267071c9
Author: Josef Bacik <jbacik@redhat.com>
Date:   Thu Mar 13 13:46:10 2008 -0400

    resize2fs: Add options to print (and resizing to) the minimum filesystem size

    Add the -P option to print the minimum filesystem size and exit.

    Add the -M option to force resizing the filesystem to the minimum
    filesystem size.

    Signed-off-by: Josef Back <jbacik@redhat.com>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>