Compare commits

...
Sign in to create a new pull request.

44 commits

Author SHA1 Message Date
Fedora Release Engineering
af0dbcb9b0 Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild 2026-07-17 09:39:51 +00:00
Fedora Release Engineering
4cf4c0d223 Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild 2026-01-17 21:07:30 +00:00
Fedora Release Engineering
d4e6241bd8 Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild 2025-07-25 21:17:30 +00:00
Fedora Release Engineering
18215950b1 Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild 2025-01-19 16:44:24 +00:00
Fedora Release Engineering
cbb4933d6c Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild 2024-07-20 10:50:39 +00:00
Fedora Release Engineering
200192e08a Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild 2024-01-27 11:04:34 +00:00
Fedora Release Engineering
3c46c06f40 Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-07-22 19:39:50 +00:00
9c9b0bfedc Update license identifier to SPDX expression 2023-03-26 17:59:16 +02:00
Fedora Release Engineering
a410add3bf Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2023-01-21 08:14:19 +00:00
Fedora Release Engineering
70a391b787 Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-07-23 13:53:43 +00:00
Fedora Release Engineering
b430910f59 - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2022-01-22 05:50:07 +00:00
Fedora Release Engineering
122852645b - Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-07-23 22:16:28 +00:00
Fedora Release Engineering
ba66b322c6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2021-01-28 00:40:44 +00:00
3f121b8d1a Spec file cleanup 2020-12-31 02:46:04 +01:00
Fedora Release Engineering
3410bc669a - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-07-29 15:21:43 +00:00
Fedora Release Engineering
f3ec65ce87 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2020-01-31 05:17:22 +00:00
Fedora Release Engineering
2ed2b6647a - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-07-27 04:58:42 +00:00
Fedora Release Engineering
b9db1a096f - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2019-02-03 13:09:45 +00:00
e9c6fdf428 Add "BuildRequires: gcc" 2018-07-16 22:45:41 +02:00
Fedora Release Engineering
e104b41434 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-07-14 09:49:18 +00:00
0de40d8416 Upgrade to 1.1.1 2018-02-20 00:06:22 +01:00
20082ff14a Upgrade to 1.1.0 2018-02-19 21:08:03 +01:00
Fedora Release Engineering
047e2d842c - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
Signed-off-by: Fedora Release Engineering <releng@fedoraproject.org>
2018-02-09 22:26:31 +00:00
Fedora Release Engineering
eb72d1d66a - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild 2017-08-03 11:10:10 +00:00
Fedora Release Engineering
f01c27fd84 - Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild 2017-07-27 22:41:52 +00:00
Fedora Release Engineering
6dd99fcb4e - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild 2017-02-11 18:23:36 +00:00
ca0a900769 Add group for EL-5 2016-04-06 01:36:27 +02:00
88a623c979 Build with ext4 support for RHEL 5 (#862934, thanks to Mike Swanson) 2016-04-06 01:22:34 +02:00
Fedora Release Engineering
fab86631be - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild 2016-02-05 04:05:18 +00:00
Dennis Gilmore
171bdc1063 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild 2015-06-19 04:45:42 +00:00
4a5bfd4eb8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild 2014-08-18 11:35:33 +00:00
Dennis Gilmore
4c51057fef - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild 2014-06-07 13:06:33 -05:00
Richard W.M. Jones
8f17ae2ce0 New upstream version 1.0.3.
- New upstream version of sparsify.c.
- Fix the license.
- Modernize the spec file.
- Remove sparsify patch (equivalent patch has gone upstream).
2013-11-18 16:39:48 +00:00
Dennis Gilmore
5bdbc0e22c - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild 2013-08-04 04:48:52 -05:00
Dennis Gilmore
92436a814c - Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild 2013-02-14 22:18:50 -06:00
Dennis Gilmore
60d5c7fa12 - Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild 2012-07-22 03:10:22 -05:00
Richard W.M. Jones
66ebe845f3 Patch sparsify to work with e2fsprogs >= 1.42. 2012-01-16 14:27:40 +00:00
Dennis Gilmore
7003017c3a - Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild 2012-01-14 03:35:27 -06:00
Dennis Gilmore
30a4e5c4e8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild 2011-02-08 02:38:41 -06:00
Fedora Release Engineering
59e6f76810 dist-git conversion 2010-07-29 16:28:53 +00:00
00ec4eeb70 Include zerofree(8) man page from Debian (RHBZ#596732). 2010-05-27 13:32:41 +00:00
Bill Nottingham
4edf733632 Fix typo that causes a failure to update the common directory. (releng
#2781)
2009-11-25 22:39:18 +00:00
Jesse Keating
5d45177a43 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild 2009-07-27 09:00:32 +00:00
c916d60d9b Initial import. 2009-05-18 08:14:24 +00:00
9 changed files with 848 additions and 21 deletions

View file

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/zerofree-*.tgz

View file

@ -1,21 +0,0 @@
# Makefile for source rpm: zerofree
# $Id$
NAME := zerofree
SPECFILE = $(firstword $(wildcard *.spec))
define find-makefile-common
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
endef
MAKEFILE_COMMON := $(shell $(find-makefile-common))
ifeq ($(MAKEFILE_COMMON),)
# attept a checkout
define checkout-makefile-common
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
endef
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
endif
include $(MAKEFILE_COMMON)

98
index.html Normal file
View file

@ -0,0 +1,98 @@
<html>
<head>
<!--
Support idiotic mobile browsers that are incapable of rendering
straightforward HTML properly
-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Keeping filesystem images sparse</title>
</head>
<body>
<h2>Keeping filesystem images sparse</h2>
<p>
Filesystem images in local files can be used by many PC emulators and
virtual machines
(<a href="http://user-mode-linux.sourceforge.net/">user-mode Linux</a>,
<a href="http://fabrice.bellard.free.fr/qemu/">QEMU</a> and
<a href="http://wiki.xensource.com/xenwiki/">Xen</a>, to name but three).
Typically these filesystems are created as sparse files using
commands like:
<p>
<pre>
dd if=/dev/zero of=fs.image bs=1024 seek=2000000 count=0
/sbin/mke2fs fs.image
</pre>
where the enormous <code>seek</code> value causes <code>dd</code> to move
forward by 2GB before writing nothing at all. This results in the
creation of a sparse file which takes disk space only for blocks which are
actually used:
<p>
<pre>
$ ls -l fs.image
-rw-rw-r-- 1 rmy rmy 2048001024 Apr 18 19:10 fs.image
$ du -s fs.image
31692 fs.image
</pre>
As the filesystem is used, more and more of the non-existent blocks are
filled with data and the size of the file on disk grows. Sometimes it would
be nice to be able to reclaim unused blocks from a filesystem image. However,
deleting files from the image doesn't return the space to the
underlying filesystem: even free blocks in the image still consume space.
Reclaiming the space can be achieved in two stages:
<ul>
<li>Fill unused blocks with zeroes
<li>Make the file sparse again
</ul>
<p>
One traditional way to zero unused blocks is to create a file that fills
all the free space:
<p>
<pre>
dd if=/dev/zero of=junk
sync
rm junk
</pre>
<p>
The disadvantage of <code>dd</code> in this context is that it destroys
any sparseness that exists: free blocks that were originally represented
as holes in the image file are replaced with actual blocks containing
zeroes. Also, filling up a live filesystem is probably a bad idea.
<p>
As an alternative approach, and as practice in mucking about with ext2
filesystems, I've written a utility which scans the free blocks in an
ext2 filesystem and fills any non-zero blocks with zeroes.
The source, <a href="zerofree-1.1.1.tgz">zerofree-1.1.1.tgz</a>, is
available for download.
<p>
<ul>
<li>A cautious user would run fsck on the filesytem both before and after
running zerofree.
<li>The filesystem to be processed should be unmounted or mounted read-only.
<li>The utility also works on ext3 or ext4 filesystems.
<li>Binary packages are available in the standard repositories for Debian and Fedora.
<li>The <a href="http://www.sysresccd.org/SystemRescueCd_Homepage">SystemRescueCd</a> live distribution includes zerofree.
<li><a href="http://libguestfs.org/">guestfish</a> can run zerofree on many types of virtual machine filesystems.
</ul>
<p>
However, this is only half the story: the empty free
blocks still consume space in the underlying filesystem, so something
must to be done to reclaim that space.
<p>
A common suggestion is to use the sparse file handling capabilities
of the GNU <code>cp</code> command to take a copy of the filesystem image with
<code>cp --sparse=always</code> (though this does require the original
and sparse files to exist at the same time, which may be inconvenient).
<p>
If your kernel and util-linux are sufficiently modern and you have a supported
filesystem you can use <code>fallocate -d</code> to 'dig holes' in a file.
This makes the file sparse in-place, without using extra disk space.
<p>
<hr>
<address>
<a href="mailto:rmy@pobox.com">Ron Yorston</a><br>
18th April 2004 (updated 19th February 2018)<br>
Some <a href="obsolete.html">obsolete</a> information has been moved to a
separate page.
</address>
</body>
</html>

View file

@ -0,0 +1 @@
SHA512 (zerofree-1.1.1.tgz) = 2d7ee57a877bff2491c48054338a26d624ae75c238ac2b0568a75de88b6621c16cc1e7d65500879825d14d8ba44a5173587a061459072769c165bee47c3f9f1c

274
sparsify.c Normal file
View file

@ -0,0 +1,274 @@
/*
* sparsify - a tool to make files on an ext2 filesystem sparse
*
* Copyright (C) 2004-2012 R M Yorston
*
* This file may be redistributed under the terms of the GNU General Public
* License, version 2.
*/
#include <ext2fs/ext2fs.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#define USAGE "usage: %s [-n] [-v] filesystem filename ...\n"
/* initially assume pre-ext4 API version */
#define API 140
#if defined(BLOCK_FLAG_READ_ONLY)
#undef API
#define API 141
#endif
#if defined(EXT2_FLAG_64BITS)
#undef API
#define API 142
#endif
struct process_data {
unsigned char *buf;
int verbose;
int dryrun;
blk_t count;
blk_t blocks;
blk_t total_blocks;
int old_percent;
};
static int process(ext2_filsys fs, blk_t *blocknr, e2_blkcnt_t blockcnt,
blk_t ref_block, int ref_offset, void *priv)
{
struct process_data *p;
errcode_t errcode;
int i, group;
int ret = 0;
p = (struct process_data *)priv;
p->blocks++;
if ( blockcnt >= 0 ) {
errcode = io_channel_read_blk(fs->io, *blocknr, 1, p->buf);
if ( errcode ) {
return BLOCK_ABORT;
}
for ( i=0; i < fs->blocksize; ++i ) {
if ( p->buf[i] ) {
break;
}
}
if ( i == fs->blocksize ) {
p->count++;
if ( !p->dryrun ) {
ext2fs_unmark_block_bitmap(fs->block_map, *blocknr);
group = ext2fs_group_of_blk(fs, *blocknr);
#if API >= 142
ext2fs_bg_free_blocks_count_set(fs, group,
ext2fs_bg_free_blocks_count(fs, group)+1);
ext2fs_free_blocks_count_add(fs->super, (blk64_t)1);
#else
fs->group_desc[group].bg_free_blocks_count++;
fs->super->s_free_blocks_count++;
#endif
#if API >= 141
ext2fs_group_desc_csum_set(fs, group);
#endif
*blocknr = 0;
ret = BLOCK_CHANGED;
}
}
if ( p->verbose ) {
double percent;
percent = 100.0 * (double)p->blocks/(double)p->total_blocks;
if ( (int)(percent*10) != p->old_percent ) {
fprintf(stderr, "\r%4.1f%%", percent);
p->old_percent = (int)(percent*10);
}
}
}
return ret;
}
int main(int argc, char **argv)
{
int verbose = 0;
int dryrun = 0;
errcode_t ret;
int flags;
int superblock = 0;
int open_flags = EXT2_FLAG_RW;
int iter_flags = 0;
int blocksize = 0;
ext2_filsys fs = NULL;
struct ext2_inode inode;
ext2_ino_t root, cwd, inum;
int i, c;
struct process_data pdata;
while ( (c=getopt(argc, argv, "nv")) != -1 ) {
switch (c) {
case 'n' :
dryrun = 1;
#if defined(BLOCK_FLAG_READ_ONLY)
iter_flags |= BLOCK_FLAG_READ_ONLY;
#endif
break;
case 'v' :
verbose = 1;
break;
default :
fprintf(stderr, USAGE, argv[0]);
return 1;
}
}
if ( argc < optind+2 ) {
fprintf(stderr, USAGE, argv[0]);
return 1;
}
ret = ext2fs_check_if_mounted(argv[optind], &flags);
if ( ret ) {
fprintf(stderr, "%s: failed to determine filesystem mount state %s\n",
argv[0], argv[optind]);
return 1;
}
if ( flags & EXT2_MF_MOUNTED ) {
fprintf(stderr, "%s: filesystem %s is mounted\n",
argv[0], argv[optind]);
return 1;
}
ret = ext2fs_open(argv[optind], open_flags, superblock, blocksize,
unix_io_manager, &fs);
if ( ret ) {
fprintf(stderr, "%s: failed to open filesystem %s\n",
argv[0], argv[optind]);
return 1;
}
pdata.buf = (unsigned char *)malloc(fs->blocksize);
if ( pdata.buf == NULL ) {
fprintf(stderr, "%s: out of memory (surely not?)\n", argv[0]);
return 1;
}
ret = ext2fs_read_inode_bitmap(fs);
if ( ret ) {
fprintf(stderr, "%s: error while reading inode bitmap\n", argv[0]);
return 1;
}
ret = ext2fs_read_block_bitmap(fs);
if ( ret ) {
fprintf(stderr, "%s: error while reading block bitmap\n", argv[0]);
return 1;
}
root = cwd = EXT2_ROOT_INO;
for ( i=optind+1; i<argc; ++i ) {
ret = ext2fs_namei(fs, root, cwd, argv[i], &inum);
if ( ret ) {
fprintf(stderr, "%s: failed to find file %s\n", argv[0], argv[i]);
continue;
}
ret = ext2fs_read_inode(fs, inum, &inode);
if ( ret ) {
fprintf(stderr, "%s: failed to open inode %d\n", argv[0], inum);
continue;
}
if ( !ext2fs_inode_has_valid_blocks(&inode) ) {
fprintf(stderr, "%s: file %s has no valid blocks\n", argv[0],
argv[i]);
continue;
}
#if defined(EXT4_EXTENTS_FL) && API < 141
if ( inode.i_flags & EXT4_EXTENTS_FL ) {
fprintf(stderr, "%s: unable to process %s, it uses extents\n",
argv[0], argv[i]);
continue;
}
#endif
#if defined(EXT4_FEATURE_RO_COMPAT_HUGE_FILE) && defined(EXT4_HUGE_FILE_FL)
if ( (fs->super->s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
&& (inode.i_flags & EXT4_HUGE_FILE_FL) ) {
fprintf(stderr, "%s: unable to process %s, it's huge\n",
argv[0], argv[i]);
continue;
}
#endif
if ( verbose ) {
printf("processing %s\n", argv[i]);
}
pdata.verbose = verbose;
pdata.dryrun = dryrun;
pdata.count = pdata.blocks = 0;
pdata.total_blocks = inode.i_blocks/(fs->blocksize >> 9);
pdata.old_percent = 1000;
ret = ext2fs_block_iterate2(fs, inum, iter_flags, NULL,
process, &pdata);
if ( ret ) {
fprintf(stderr, "%s: failed to process file %s\n", argv[0],
argv[i]);
continue;
}
if ( pdata.count && !dryrun ) {
ext2fs_mark_bb_dirty(fs);
ext2fs_mark_super_dirty(fs);
ret = ext2fs_read_inode(fs, inum, &inode);
if ( ret ) {
fprintf(stderr, "%s: failed to open inode (%s)\n", argv[0],
argv[i]);
continue;
}
#if API >= 141
ret = ext2fs_iblk_sub_blocks(fs, &inode, (blk64_t)pdata.count);
if ( ret ) {
fprintf(stderr, "%s: failed to update block count (%s)\n",
argv[0], argv[i]);
continue;
}
#else
inode.i_blocks -= pdata.count * (fs->blocksize >> 9);
#endif
ret = ext2fs_write_inode(fs, inum, &inode);
if ( ret ) {
fprintf(stderr, "%s: failed to write inode (%s)\n",
argv[0], argv[i]);
continue;
}
}
if ( verbose ) {
printf("\r%d/%d/%d %s\n", pdata.count, pdata.blocks,
pdata.total_blocks, argv[i]);
}
}
ret = ext2fs_close(fs);
if ( ret ) {
fprintf(stderr, "%s: error while closing filesystem\n", argv[0]);
return 1;
}
return 0;
}

96
zerofree.8 Normal file
View file

@ -0,0 +1,96 @@
.TH "ZEROFREE" "8"
.SH "NAME"
zerofree \(em zero free blocks from ext2, ext3 and ext4 file-systems
.SH "SYNOPSIS"
.PP
\fBzerofree\fR [\fB-n\fP] [\fB-v\fP] [\fB-f fillval\fP] \fIfilesystem\fR
.SH "DESCRIPTION"
.PP
\fBzerofree\fR finds the unallocated,
blocks with non-zero value content in an ext2, ext3 or ext4
\fIfilesystem\fR (e.g. /dev/hda1) and
fills them with zeroes (or another octet of your choice).
.PP
Filling unused areas with zeroes is useful if the device on
which this file-system resides is a disk image. In this case,
depending on the type of disk image, a secondary utility may be
able to reduce the size of the disk image after zerofree has
been run.
.PP
Filling unused areas may also be useful with solid-state
drives (SSDs). On some SSDs, filling blocks with ones (0xFF)
is reported to trigger Flash block erasure by the firmware,
possibly giving a write performance increase.
.PP
The usual way to achieve the same result (zeroing the
unallocated blocks) is to run \fBdd\fR (1) to
create a file full of zeroes that takes up the entire free
space on the drive, and then delete this file. This has many
disadvantages, which zerofree alleviates:
.IP " \(bu" 6
it is slow;
.IP " \(bu" 6
it makes the disk image (temporarily) grow to its maximal
extent;
.IP " \(bu" 6
it (temporarily) uses all free space on the disk, so other
concurrent write actions may fail.
.PP
\fIfilesystem\fR has to be unmounted or
mounted read-only for \fBzerofree\fR to work. It
will exit with an error message if the
\fIfilesystem\fR is mounted writable. To
remount the root file-system readonly, you can first switch to
single user runlevel (\fBtelinit 1\fR) then use
\fBmount \-o remount,ro
\fIfilesystem\fR\fR.
.PP
\fBzerofree\fR has been written to be run
from GNU/Linux systems installed as guest OSes inside a virtual
machine. In this case, it is typically run from within the guest
system, and a utility is then run from the host system to shrink
disk image (\fBVBoxManage modifyhd \-\-compact\fR,
provided with virtualbox, is able to do that for some disk image
formats).
.PP
It may however be useful in other situations: for instance
it can be used to make it more difficult to retrieve deleted
data. Beware that securely deleting sensitive data is not in
general an easy task and usually requires writing several times
on the deleted blocks.
.SH "OPTIONS"
.IP "\fB-n\fP " 10
Perform a dry run (do not modify the file-system);
.IP "\fB-v\fP " 10
Be verbose: show the number of blocks modified by
\fBzerofree\fR (or that would be modified,
in case the \fB-n\fP is used), the number of free
blocks and the total number of blocks on the
filesystem;
.IP "\fB-f value\fP " 10
Specify the octet value to fill empty blocks with (defaults to
0). Argument must be within the range 0 to 255.
.SH "SEE ALSO"
.PP
dd (1).
.SH "AUTHOR"
.PP
This manual page was written by Thibaut Paumard <paumard@users.sourceforge.net> for
the \fBDebian\fP system (but may be used by others). Permission is
granted to copy, distribute and/or modify this document under
the terms of the GNU General Public License, Version 2 or any
later version published by the Free Software Foundation.
.PP
On Debian systems, the complete text of the GNU General Public
License can be found in /usr/share/common-licenses/GPL-2.
.\" created by instant / docbook-to-man, Thu 31 Dec 2020, 01:06

193
zerofree.sgml Normal file
View file

@ -0,0 +1,193 @@
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
<!-- Process this file with docbook-to-man to generate an nroff manual
page: `docbook-to-man manpage.sgml > manpage.1'. You may view
the manual page with: `docbook-to-man manpage.sgml | nroff -man |
less'.
-->
<!ENTITY dhfirstname "<firstname>Thibaut</firstname>">
<!ENTITY dhsurname "<surname>Paumard</surname>">
<!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>April 3rd, 2012</date>">
<!ENTITY dhsection "<manvolnum>8</manvolnum>">
<!ENTITY dhemail "<email>&lt;paumard@users.sourceforge.net&gt;</email>">
<!ENTITY dhusername "Thibaut Paumard">
<!ENTITY dhucpackage "<refentrytitle>ZEROFREE</refentrytitle>">
<!ENTITY dhpackage "zerofree">
<!ENTITY debian "<productname>Debian</productname>">
<!ENTITY gnu "<acronym>GNU</acronym>">
<!ENTITY gpl "&gnu; <acronym>GPL</acronym>">
]>
<refentry>
<refentryinfo>
<address>
&dhemail;
</address>
<author>
&dhfirstname;
&dhsurname;
</author>
<copyright>
<year>2003</year>
<holder>&dhusername;</holder>
</copyright>
&dhdate;
</refentryinfo>
<refmeta>
&dhucpackage;
&dhsection;
</refmeta>
<refnamediv>
<refname>&dhpackage;</refname>
<refpurpose>zero free blocks from ext2, ext3 and ext4 file-systems</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg><option>-n</option></arg>
<arg><option>-v</option></arg>
<arg><option>-f fillval</option></arg>
<arg choice=req><replaceable>filesystem</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>DESCRIPTION</title>
<para><command>&dhpackage;</command> finds the unallocated,
blocks with non-zero value content in an ext2, ext3 or ext4
<replaceable>filesystem</replaceable> (e.g. /dev/hda1) and
fills them with zeroes (or another octet of your choice).
<para>Filling unused areas with zeroes is useful if the device on
which this file-system resides is a disk image. In this case,
depending on the type of disk image, a secondary utility may be
able to reduce the size of the disk image after zerofree has
been run.</para>
<para>Filling unused areas may also be useful with solid-state
drives (SSDs). On some SSDs, filling blocks with ones (0xFF)
is reported to trigger Flash block erasure by the firmware,
possibly giving a write performance increase.</para>
<para>The usual way to achieve the same result (zeroing the
unallocated blocks) is to run <command>dd</command> (1) to
create a file full of zeroes that takes up the entire free
space on the drive, and then delete this file. This has many
disadvantages, which zerofree alleviates:</para>
<itemizedlist>
<listitem><para>it is slow;</para></listitem>
<listitem><para>it makes the disk image (temporarily) grow to its maximal
extent;</para></listitem>
<listitem><para>it (temporarily) uses all free space on the disk, so other
concurrent write actions may fail.</para></listitem>
</itemizedlist>
<para><replaceable>filesystem</replaceable> has to be unmounted or
mounted read-only for <command>&dhpackage;</command> to work. It
will exit with an error message if the
<replaceable>filesystem</replaceable> is mounted writable. To
remount the root file-system readonly, you can first switch to
single user runlevel (<command>telinit 1</command>) then use
<command>mount -o remount,ro
<replaceable>filesystem</replaceable></command>.</para>
<para><command>&dhpackage;</command> has been written to be run
from GNU/Linux systems installed as guest OSes inside a virtual
machine. In this case, it is typically run from within the guest
system, and a utility is then run from the host system to shrink
disk image (<command>VBoxManage modifyhd --compact</command>,
provided with virtualbox, is able to do that for some disk image
formats).</para>
<para>It may however be useful in other situations: for instance
it can be used to make it more difficult to retrieve deleted
data. Beware that securely deleting sensitive data is not in
general an easy task and usually requires writing several times
on the deleted blocks.</para>
</refsect1>
<refsect1>
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term><option>-n</option>
</term>
<listitem>
<para>Perform a dry run (do not modify the file-system);</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option>
</term>
<listitem>
<para>Be verbose: show the number of blocks modified by
<command>&dhpackage;</command> (or that would be modified,
in case the <option>-n</option> is used), the number of free
blocks and the total number of blocks on the
filesystem;</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-f value</option>
</term>
<listitem>
<para>Specify the octet value to fill empty blocks with (defaults to
0). Argument must be within the range 0 to 255.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>dd (1).</para>
</refsect1>
<refsect1>
<title>AUTHOR</title>
<para>This manual page was written by &dhusername; &dhemail; for
the &debian; system (but may be used by others). Permission is
granted to copy, distribute and/or modify this document under
the terms of the &gnu; General Public License, Version 2 or any
later version published by the Free Software Foundation.
</para>
<para>
On Debian systems, the complete text of the GNU General Public
License can be found in /usr/share/common-licenses/GPL-2.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

185
zerofree.spec Normal file
View file

@ -0,0 +1,185 @@
Summary: Utility to force unused ext2/3/4 inodes and blocks to zero
Name: zerofree
Version: 1.1.1
Release: 18%{?dist}
License: GPL-2.0-only
URL: https://frippery.org/uml/
Source0: https://frippery.org/uml/%{name}-%{version}.tgz
Source1: https://frippery.org/uml/sparsify.c
Source2: https://frippery.org/uml/index.html
# zerofree.sgml is the source for the man page from Debian.
# Unfortunately we cannot build this in Fedora because we do not have
# docbook-to-man, just docbook2man and db2x_docbook2man. The included
# man page was generated on a Debian system from this source.
Source3: zerofree.sgml
Source4: zerofree.8
BuildRequires: gcc
BuildRequires: make
BuildRequires: e2fsprogs-devel
%description
zerofree is a utility to set unused filesystem inodes and blocks of an
ext2/3/4 filesystem to zero. This can improve the compressibility and
privacy of an ext2/3/4 filesystem.
This tool was inspired by the ext2fs privacy (i.e. secure deletion)
patch described in a Linux kernel mailing list thread.
WARNING: The filesystem to be processed should be unmounted or mounted
read-only. The tool tries to check this before running, but you
should be careful.
%prep
%setup -q
cp -p %{SOURCE1} %{SOURCE2} .
%build
make CC="%{__cc} $RPM_OPT_FLAGS $RPM_LD_FLAGS"
%{__cc} $RPM_OPT_FLAGS $RPM_LD_FLAGS -o sparsify sparsify.c -lext2fs
%install
install -D -p -m 755 zerofree $RPM_BUILD_ROOT%{_sbindir}/zerofree
install -D -p -m 755 sparsify $RPM_BUILD_ROOT%{_sbindir}/sparsify
install -D -p -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_mandir}/man8/zerofree.8
%files
%license COPYING
%doc index.html
%{_sbindir}/zerofree
%{_sbindir}/sparsify
%{_mandir}/man8/zerofree.8*
%changelog
* Fri Jul 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-18
- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
* Sat Jan 17 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-17
- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild
* Fri Jul 25 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-16
- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild
* Sun Jan 19 2025 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild
* Sat Jul 20 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Thu Jan 28 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Feb 20 2018 Robert Scheck <robert@fedoraproject.org> - 1.1.1-1
- Upgrade to 1.1.1
* Mon Feb 19 2018 Robert Scheck <robert@fedoraproject.org> - 1.1.0-1
- Upgrade to 1.1.0
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.3-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.3-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.3-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Wed Apr 06 2016 Robert Scheck <robert@fedoraproject.org> - 1.0.3-6
- Build with ext4 support for RHEL 5 (#862934, thanks to Mike Swanson)
* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Mon Aug 18 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Mon Nov 18 2013 Richard W.M. Jones <rjones@redhat.com> - 1.0.3-1
- New upstream version 1.0.3.
- New upstream version of sparsify.c.
- Fix the license.
- Modernize the spec file.
- Remove sparsify patch (equivalent patch has gone upstream).
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Fri Feb 15 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-12
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Mon Jan 16 2012 Richard W.M. Jones <rjones@redhat.com> - 1.0.1-10
- Patch sparsify to work with e2fsprogs >= 1.42.
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Thu May 27 2010 Richard W.M. Jones <rjones@redhat.com> - 1.0.1-7
- Include zerofree(8) man page from Debian (RHBZ#596732).
* Mon Jul 27 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
* Fri May 15 2009 Richard W.M. Jones <rjones@redhat.com> - 1.0.1-5
- Include the index file as a source file.
- Improve the description, remove spelling mistakes and other typos.
- Use the upstream SRPM directly, unpacking source from it.
- Fix use of dist macro.
- Pass the RPM OPTFLAGS to C compiler (should also fix debuginfo pkg).
- Use 'cp -p' to preserve timestamps when copying index.html file.
- Fix the defattr line.
- License is GPL+ (any version of the GPL including 1).
- Use a simpler install command to install the binary.
- Fix the upstream URL to point to the real original project.
- Add the sparsify command.
* Thu May 14 2009 Richard W.M. Jones <rjones@redhat.com> - 1.0.1-1
- Initial packaging for Fedora, based on R P Herrold's package.
* Wed May 13 2009 R P Herrold <info@owlriver.com> - 1.0.1-1
- initial packaging