Preliminary version of resize_ffs, based on der Mouse's fsresize tool.

I didn't have time to clean it up completely before my legal status
w.r.t. open source projects goes into limbo for a while.  Other
developers are encouraged to play with the tool and get it into
release-worthy shape.

TODO list (see TODO file)

* verify it builds on -current, put it into release lists/etc. and src/sbin/Makefile
  (built & tested on 1.6.1)
* make it ask questions before doing any work (confirm)
* create regression test suite (see discussions on tech-kern and
  developers) and fix any bugs
* verify conversion to ANSI C didn't break anything
* port to UFS2
This commit is contained in:
jtk 2003-02-21 04:08:54 +00:00
parent aeb8d0ecad
commit ec57cc7eb3
4 changed files with 2009 additions and 0 deletions

6
sbin/resize_ffs/Makefile Normal file
View File

@ -0,0 +1,6 @@
# $NetBSD: Makefile,v 1.1 2003/02/21 04:08:54 jtk Exp $
PROG=resize_ffs
MAN=resize_ffs.8
.include <bsd.prog.mk>

15
sbin/resize_ffs/TODO Normal file
View File

@ -0,0 +1,15 @@
Preliminary version of resize_ffs, based on der Mouse's fsresize tool.
I didn't have time to clean it up completely before my legal status
w.r.t. open source projects goes into limbo for a while. Other
developers are encouraged to play with the tool and get it into
release-worthy shape.
TODO list (see TODO file)
* verify it builds on -current, put it into release lists/etc. and src/sbin/Makefile
(built & tested on 1.6.1)
* make it ask questions before doing any work (confirm)
* create regression test suite (see discussions on tech-kern and
developers) and fix any bugs
* verify conversion to ANSI C didn't break anything
* port to UFS2

View File

@ -0,0 +1,105 @@
.\" $NetBSD: resize_ffs.8,v 1.1 2003/02/21 04:08:55 jtk Exp $
.\" As its sole author, I explicitly place this man page in the public
.\" domain. Anyone may use it in any way for any purpose (though I would
.\" appreciate credit where it is due).
.\"
.\" /~\ The ASCII der Mouse
.\" \ / Ribbon Campaign
.\" X Against HTML mouse@rodents.montreal.qc.ca
.\" / \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B
.Dd February 20, 2003
.Dt RESIZE_FFS 8
.Sh NAME
.Nm resize_ffs
.Nd resize an on-disk filesystem
.Sh SYNOPSIS
.Nm
.Ar filesystem-raw-device
.Ar newsize
.Sh DESCRIPTION
.Nm
resizes a filesystem on disk.
.Ar filesystem
is the name of the raw disk device where the filesystem resides;
.Ar newsize
is the desired new filesystem size, in sectors. (Sectors are almost
always 512 bytes, and
.Nm
can both grow and shrink filesystems. When growing, the disk device
must of course be large enough to contain the new filesystem;
.Nm
simply extends the filesystem data structures into the new space. When
shrinking,
.Nm
assumes this. It will not work correctly for filesystems with other
sector sizes.)
.Nm
has to copy anything that currently resides in the space being shrunk
away; there must be enough space free on the filesystem for this to
succeed. If there isn't,
.Nm
will complain and exit; when this happens, it attempts to always leave
the filesystem in a consistent state, but it is probably a good idea to
check the filesystem with
.Xr fsck 8 .
.Pp
.Sh WARNING
.Nm
should still be considered experimental. It still needs to be validated
with a rigorous regression test suite.
.Em Interrupting
.Nm
.Em "may leave your file system in an inconsistent state and require a"
.Em "restore from backup."
It attempts to write in the proper order to avoid problems, but as it is
still considered experimental, you should take great care when using it.
.Pp
When
.Nm
is applied to a consistent filesystem, it should always produce a
consistent filesystem; if the filesystem is not consistent to start
with,
.Nm
may misbehave, anything from dumping core to completely curdling the
data. It's probably wise to
.Xr fsck 8
the filesystem before and after, just to be safe.
.\" Remove this when (if) fsck gets fixed.
.Pp
There is a bug somewhere in fsck; it does not check certain data
structures enough. A past version of this program had a bug that
produced corrupted rotation layout summary tables, which would panic
the kernel. This bug is believed fixed, and there are currently no
known bugs in the program. However, you should be aware that just
because fsck is happy with the filesystem does not mean it is intact.
.Sh EXAMPLES
.Nm
.Li /dev/rsd1e 29574
.Sh SEE ALSO
.Xr fs 5 ,
.Xr newfs 8 ,
.Xr fsck 8
.Sh AUTHOR
.Li der Mouse <mouse@rodents.montreal.qc.ca>
.Pp
A big bug-finding kudos goes to John Kohl for finding the rotational
layout bug referred
to in the WARNING section above.
.Sh BUGS
Has not been tested and probably won't work on opposite-endian file
systems.
.Pp
Can fail to shrink a filesystem when there actually is enough space,
because it does not distinguish between a block allocated as a block
and a block fully occupied by two or more frags. This is unlikely to
occur in practice; except for pathological cases, it can happen only
when the new size is extremely close to the minimum possible.
.Pp
Has no intelligence whatever when it comes to allocating blocks to copy
data into when shrinking.
.Sh HISTORY
The
.Nm
command first appeared in
.Nx 2.0 .

1883
sbin/resize_ffs/resize_ffs.c Normal file

File diff suppressed because it is too large Load Diff