fallocate: command not found

“fallocate” is a command-line tool in Linux-based systems that allows a user to reserve or deallocate disk space to files. This means that the user can allocate disk space to a file without actually writing data to the disk, or deallocate the disk space from a file without deleting the file itself.

The main advantage of using fallocate over other tools such as “dd” or “truncate” is that it can allocate or deallocate disk space without zeroing the data. This means that it does not need to write zeroes to the disk, which can be much faster than zeroing the data.

The fallocate command can be used to perform various operations on files such as:

  • Reserve disk space for a file: This will allocate disk space for a file without writing any data to it. This can be useful for creating large files that will be filled later, or for reserving space for a file that will be used as a swap file.
  • Deallocate disk space from a file: This will deallocate disk space from a file without deleting the file itself. This can be useful for shrinking a file to a smaller size, or for releasing space that is no longer needed.
  • Punch hole in a file: This will deallocate disk space from a file by creating a hole (a region of a file that contains no data) in it. This can be useful for reducing the physical size of a file, or for releasing space that is no longer needed.
  • Preallocate space for a file: This will allocate disk space for a file by writing zeroes to it. This can be useful for creating large files that will be filled later, or for reserving space for a file that will be used as a swap file.

If you encounter the below error while running the command fallocate:

fallocate: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install util-linux
Ubuntu apt-get install util-linux
Alpine apk add util-linux
Arch Linux pacman -S util-linux
Kali Linux apt-get install util-linux
CentOS yum install util-linux
Fedora dnf install util-linux
OS X brew install util-linux
Raspbian apt-get install util-linux

fallocate Command Examples

1. Reserve a file taking up 700 MiB of disk space:

# fallocate --length 700M path/to/file

2. Shrink an already allocated file by 200 MiB:

# fallocate --collapse-range --length 200M path/to/file

3. Shrink 20 MB of space after 100 MiB in a file:

# fallocate --collapse-range --offset 100M --length 20M path/to/file
Related Post