diff --git a/index.html b/index.html index 2a0b312..c779213 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,5 @@ - - Keeping filesystem images sparse @@ -56,13 +51,14 @@ all the free space: The disadvantage of dd 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. +zeroes.

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, zerofree-1.1.1.tgz, is -available for download. +The source, zerofree-1.0.3.tgz, is +available for download. It's also available in a git repository: +git clone http://intgat.tigress.co.uk/rmy/git/zerofree.git

-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. +Better than either of these would be to have the guest kernel keep the free +blocks empty. My original inspiration was the + +ext2fs privacy (i.e. secure deletion) patch described in a Linux +kernel mailing list thread. I've also made use of a later patch for ext3 +entitled +Secure Deletion Functionality in ext3 +from the linux-fsdevel mailing list. (See also the authors' paper on +Secure Deletion File Systems.) +I've modified the patches to make them more suitable for the present purpose. +

+When a filesystem is mounted with the zerofree option (added +by these patches) all the blocks freed when a file is deleted are filled +with zeroes. +Remember, this extra work will hurt disk performance. +Note that the ext3 patch doesn't support data journalling +mode, so deleted metadata isn't zeroed. It also hasn't been tested +as thoroughly as the patch for ext2. And neither has been maintained for a +very long time.

-A common suggestion is to use the sparse file handling capabilities +However, the above techniques are 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. For filesystems and kernels that +support it the fallocate call with FALLOC_FL_PUNCH_HOLE can +be used to deallocate space in a file. +

+An existing alternative is to use the sparse file handling capabilities of the GNU cp command to take a copy of the filesystem image with cp --sparse=always (though this does require the original and sparse files to exist at the same time, which may be inconvenient).

-If your kernel and util-linux are sufficiently modern and you have a supported -filesystem you can use fallocate -d to 'dig holes' in a file. -This makes the file sparse in-place, without using extra disk space. +As an alternative alternative I've written a utility which can make +any specified files on an ext2 filesystem +sparse, sparsify.c. This doesn't require any +additional disk space to work its magic, but it does require that the +filesystem containing the filesystem image is unmounted, which is just a +different sort of inconvenience. +

+

+

+As an example, suppose we have an unmounted filesystem +image, fs.image, in the directory /data, which is the +root of the /dev/hda2 filesystem. We can reclaim deleted +blocks and make it sparse like so: +

+

+   zerofree /data/fs.image
+   umount /data
+   sparsify /dev/hda2 /fs.image
+   mount /data
+


-Ron Yorston
-18th April 2004 (updated 19th February 2018)
-Some obsolete information has been moved to a -separate page. +Ron Yorston
+9th August 2012
diff --git a/sources b/sources index 05a7873..38a03b9 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (zerofree-1.1.1.tgz) = 2d7ee57a877bff2491c48054338a26d624ae75c238ac2b0568a75de88b6621c16cc1e7d65500879825d14d8ba44a5173587a061459072769c165bee47c3f9f1c +7fffca9639a2acc9c889c49b3f94a0c6 zerofree-1.0.3.tgz diff --git a/zerofree.8 b/zerofree.8 index ee306b5..b0be0d2 100644 --- a/zerofree.8 +++ b/zerofree.8 @@ -1,36 +1,25 @@ .TH "ZEROFREE" "8" .SH "NAME" -zerofree \(em zero free blocks from ext2, ext3 and ext4 file-systems +zerofree \(em zero free blocks from ext2/3 file-systems .SH "SYNOPSIS" .PP -\fBzerofree\fR [\fB-n\fP] [\fB-v\fP] [\fB-f fillval\fP] \fIfilesystem\fR +\fBzerofree\fR [\fB-n\fP] [\fB-v\fP] \fIfilesystem\fR .SH "DESCRIPTION" .PP \fBzerofree\fR finds the unallocated, -blocks with non-zero value content in an ext2, ext3 or ext4 +non-zeroed blocks in an ext2 or ext3 \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, +fills them with zeroes. This 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. - +been run. .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: +disadvantages, which zerofree alleviates: .IP " \(bu" 6 it is slow; .IP " \(bu" 6 @@ -38,8 +27,7 @@ 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. - +concurrent write actions may fail. .PP \fIfilesystem\fR has to be unmounted or mounted read-only for \fBzerofree\fR to work. It @@ -48,36 +36,17 @@ will exit with an error message if the 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. - +\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. - +\fBzerofree\fR has been written to be +run from GNU/Linux systems installed as guest OSes inside a +virtual machine. It may however be useful in other +situations. .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. +Be verbose. .SH "SEE ALSO" .PP dd (1). @@ -93,4 +62,4 @@ later version published by the Free Software Foundation. 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 +.\" created by instant / docbook-to-man, Wed 25 Nov 2009, 17:45 diff --git a/zerofree.sgml b/zerofree.sgml index 1c40f71..e5c43a3 100644 --- a/zerofree.sgml +++ b/zerofree.sgml @@ -9,7 +9,7 @@ Thibaut"> Paumard"> - April 3rd, 2012"> + February 6, 2008"> 8"> <paumard@users.sourceforge.net>"> @@ -44,7 +44,7 @@ &dhpackage; - zero free blocks from ext2, ext3 and ext4 file-systems + zero free blocks from ext2/3 file-systems @@ -54,8 +54,6 @@ - - filesystem @@ -63,21 +61,14 @@ DESCRIPTION &dhpackage; finds the unallocated, - blocks with non-zero value content in an ext2, ext3 or ext4 + non-zeroed blocks in an ext2 or ext3 filesystem (e.g. /dev/hda1) and - fills them with zeroes (or another octet of your choice). - - Filling unused areas with zeroes is useful if the device on - which this file-system resides is a disk image. In this case, + fills them with zeroes. This 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. - 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. - The usual way to achieve the same result (zeroing the unallocated blocks) is to run dd (1) to create a file full of zeroes that takes up the entire free @@ -103,19 +94,10 @@ mount -o remount,ro filesystem. - &dhpackage; 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 (VBoxManage modifyhd --compact, - provided with virtualbox, is able to do that for some disk image - formats). - - 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. + &dhpackage; has been written to be + run from GNU/Linux systems installed as guest OSes inside a + virtual machine. It may however be useful in other + situations. @@ -133,19 +115,7 @@ - Be verbose: show the number of blocks modified by - &dhpackage; (or that would be modified, - in case the is used), the number of free - blocks and the total number of blocks on the - filesystem; - - - - - - - Specify the octet value to fill empty blocks with (defaults to - 0). Argument must be within the range 0 to 255. + Be verbose. diff --git a/zerofree.spec b/zerofree.spec index 45118bc..b906d9a 100644 --- a/zerofree.spec +++ b/zerofree.spec @@ -1,26 +1,29 @@ -Summary: Utility to force unused ext2/3/4 inodes and blocks to zero +Summary: Utility to force unused ext2 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 +Version: 1.0.3 +Release: 4%{?dist} +License: GPL+ + +URL: http://intgat.tigress.co.uk/rmy/uml/ + +Source0: http://intgat.tigress.co.uk/rmy/uml/%{name}-%{version}.tgz +Source1: http://intgat.tigress.co.uk/rmy/uml/sparsify.c +Source2: http://intgat.tigress.co.uk/rmy/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. +# Unfortunately we cannot build this in Fedora because of an apparent +# bug in our DocBook tools. Therefore I also include the generated +# man page (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. +ext2 filesystem to zero. This can improve the compressibility and +privacy of an ext2 filesystem. This tool was inspired by the ext2fs privacy (i.e. secure deletion) patch described in a Linux kernel mailing list thread. @@ -29,102 +32,32 @@ 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} . +cp -p %{SOURCE1} . +cp -p %{SOURCE2} . + %build -make CC="%{__cc} $RPM_OPT_FLAGS $RPM_LD_FLAGS" -%{__cc} $RPM_OPT_FLAGS $RPM_LD_FLAGS -o sparsify sparsify.c -lext2fs +make CC="gcc $RPM_OPT_FLAGS" +gcc $RPM_OPT_FLAGS sparsify.c -o sparsify -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 +%doc COPYING index.html %{_sbindir}/zerofree %{_sbindir}/sparsify %{_mandir}/man8/zerofree.8* + %changelog -* Fri Jul 17 2026 Fedora Release Engineering - 1.1.1-18 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild - -* Sat Jan 17 2026 Fedora Release Engineering - 1.1.1-17 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild - -* Fri Jul 25 2025 Fedora Release Engineering - 1.1.1-16 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - -* Sun Jan 19 2025 Fedora Release Engineering - 1.1.1-15 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild - -* Sat Jul 20 2024 Fedora Release Engineering - 1.1.1-14 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild - -* Sat Jan 27 2024 Fedora Release Engineering - 1.1.1-13 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild - -* Sat Jul 22 2023 Fedora Release Engineering - 1.1.1-12 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild - -* Sat Jan 21 2023 Fedora Release Engineering - 1.1.1-11 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - -* Sat Jul 23 2022 Fedora Release Engineering - 1.1.1-10 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - -* Sat Jan 22 2022 Fedora Release Engineering - 1.1.1-9 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Fri Jul 23 2021 Fedora Release Engineering - 1.1.1-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Thu Jan 28 2021 Fedora Release Engineering - 1.1.1-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Wed Jul 29 2020 Fedora Release Engineering - 1.1.1-6 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Fri Jan 31 2020 Fedora Release Engineering - 1.1.1-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Sat Jul 27 2019 Fedora Release Engineering - 1.1.1-4 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - -* Sun Feb 03 2019 Fedora Release Engineering - 1.1.1-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild - -* Sat Jul 14 2018 Fedora Release Engineering - 1.1.1-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild - -* Tue Feb 20 2018 Robert Scheck - 1.1.1-1 -- Upgrade to 1.1.1 - -* Mon Feb 19 2018 Robert Scheck - 1.1.0-1 -- Upgrade to 1.1.0 - -* Fri Feb 09 2018 Fedora Release Engineering - 1.0.3-10 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild - -* Thu Aug 03 2017 Fedora Release Engineering - 1.0.3-9 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild - -* Thu Jul 27 2017 Fedora Release Engineering - 1.0.3-8 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild - -* Sat Feb 11 2017 Fedora Release Engineering - 1.0.3-7 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild - -* Wed Apr 06 2016 Robert Scheck - 1.0.3-6 -- Build with ext4 support for RHEL 5 (#862934, thanks to Mike Swanson) - -* Fri Feb 05 2016 Fedora Release Engineering - 1.0.3-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild - * Fri Jun 19 2015 Fedora Release Engineering - 1.0.3-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild