• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

fallocate: command not found

by Deepika

“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

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to backup/restore configuration using authconfig
  2. CentOS / RHEL : How to restrict SSH login by time of day
  3. createrepo Command Examples in Linux
  4. How to Setup a squid proxy server on CentOS/RHEL 7
  5. How to setup passwordless SSH login in Linux
  6. How to Install and Configure Kerberos in CentOS/RHEL 7
  7. How to Compress and Extract Files and Directories in Linux Using gzip and bzip2
  8. mcookie: command not found
  9. How to use fdisk to partition a disk in Linux
  10. CentOS / RHEL 5, 6 : how to disable NetworkManager

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright