{
    "mode": "man",
    "parameter": "zerofree",
    "section": "8",
    "url": "https://www.chedong.com/phpMan.php/man/zerofree/8/json",
    "generated": "2026-10-09T13:02:24Z",
    "synopsis": "zerofree [-n]  [-v]  [-f fillval]  filesystem",
    "sections": {
        "NAME": {
            "content": "zerofree — zero free blocks from ext2, ext3 and ext4 file-systems\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "zerofree [-n]  [-v]  [-f fillval]  filesystem\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "zerofree  finds  the unallocated, blocks with non-zero value content in an ext2, ext3 or ext4\nfilesystem (e.g. /dev/hda1) and fills them with zeroes (or another octet of your choice).\n\n\n\nFilling unused areas with zeroes is useful if the device on which this file-system resides is\na disk image. In this case, depending on the type of disk image, a secondary utility  may  be\nable to reduce the size of the disk image after zerofree has been run.\n\n\nFilling unused areas may also be useful with solid-state drives (SSDs). On some SSDs, filling\nblocks  with ones (0xFF) is reported to trigger Flash block erasure by the firmware, possibly\ngiving a write performance increase.\n\n\nThe usual way to achieve the same result (zeroing the unallocated blocks) is to run dd (1) to\ncreate a file full of zeroes that takes up the entire free  space  on  the  drive,  and  then\ndelete this file. This has many disadvantages, which zerofree alleviates:\n\n•  it is slow;\n\n•  it makes the disk image (temporarily) grow to its maximal extent;\n\n•  it (temporarily) uses all free space on the disk, so other concurrent write actions may\nfail.\n\n\nfilesystem  has  to be unmounted or mounted read-only for zerofree to work. It will exit with\nan error message if the filesystem is mounted writable. To remount the root file-system read‐\nonly, you can first switch to single user runlevel (telinit 1) then use mount  -o  remount,ro\nfilesystem.\n\n\nzerofree  has  been written to be run from GNU/Linux systems installed as guest OSes inside a\nvirtual machine. In this case, it is typically run from within the guest system, and a  util‐\nity  is  then  run  from the host system to shrink disk image (VBoxManage modifyhd --compact,\nprovided with virtualbox, is able to do that for some disk image formats).\n\n\nIt may however be useful in other situations: for instance it can be used  to  make  it  more\ndifficult  to  retrieve  deleted data. Beware that securely deleting sensitive data is not in\ngeneral an easy task and usually requires writing several times on the deleted blocks.\n\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-n",
                    "content": "",
                    "flag": "-n"
                },
                {
                    "name": "-v",
                    "content": "fied,  in  case  the -n is used), the number of free blocks and the total number of\nblocks on the filesystem;\n",
                    "flag": "-v"
                },
                {
                    "name": "-f value",
                    "content": "within the range 0 to 255.\n",
                    "flag": "-f"
                }
            ]
        },
        "SEE ALSO": {
            "content": "dd (1).\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "This manual page was written by Thibaut Paumard <paumard@users.sourceforge.net> for  the  De‐\nbian  system  (but  may be used by others).  Permission is granted to copy, distribute and/or\nmodify this document under the terms of the GNU General Public  License,  Version  2  or  any\nlater version published by the Free Software Foundation.\n\n\nOn  Debian  systems,  the  complete  text  of  the GNU General Public License can be found in\n/usr/share/common-licenses/GPL-2.\n\n\nZEROFREE(8)",
            "subsections": []
        }
    },
    "summary": "zerofree — zero free blocks from ext2, ext3 and ext4 file-systems",
    "flags": [
        {
            "flag": "-n",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-v",
            "long": null,
            "arg": null,
            "description": "fied, in case the -n is used), the number of free blocks and the total number of blocks on the filesystem;"
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": "within the range 0 to 255."
        }
    ],
    "examples": [],
    "see_also": []
}