Forrest logo
tool overview
On this page you find all important commands for the CLI tool fallocate. If the command you are looking for is missing please ask our AI.

fallocate

Fallocate is a command line tool in Linux used to allocate space to a file. It is a part of the GNU Core Utilities. The primary purpose of fallocate is to preallocate space on a file system, typically for use by large files. It allows users to specify the size of the allocated space for a file, even if no data is written to it yet.

Fallocate works by utilizing the fallocate system call, which directly manipulates the file system's free space map. This makes it a faster alternative to other methods like writing zeroes or random data to a file for space allocation.

The tool supports various options, such as --keep-size, which preserves the existing size of the file if it already exists. Another useful option is --dig-holes, which finds ranges of zeros in a file and marks them as unallocated, enabling space saving in sparse files.

Fallocate is commonly used by system administrators and developers working with large files or file systems that require preallocation. It can also be helpful in testing storage devices or simulating disk full scenarios.

It is important to note that fallocate requires the user to have appropriate permissions to allocate space on a given file system. Additionally, not all file systems support the fallocate system call, so its functionality is dependent on the underlying file system being used.

List of commands for fallocate:

  • fallocate:tldr:a7a1f fallocate: Shrink 20 MB of space after 100 MiB in a file.
    $ fallocate --collapse-range --offset ${100M} --length ${20M} ${filename}
    try on your machine
    explain this command
  • fallocate:tldr:b1883 fallocate: Reserve a file taking up 700 MiB of disk space.
    $ fallocate --length ${700M} ${filename}
    try on your machine
    explain this command
  • fallocate:tldr:dffe8 fallocate: Shrink an already allocated file by 200 MiB.
    $ fallocate --collapse-range --length ${200M} ${filename}
    try on your machine
    explain this command
tool overview