# man > fallocate(1)

---
type: CommandReference
command: fallocate
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `fallocate -l 700M path/to/file` — Reserve a file taking up 700 MiB of disk space.
- `fallocate -c -l 200MB path/to/file` — Shrink an already allocated file by 200 MB.
- `fallocate -c -o 100M -l 20M path/to/file` — Shrink 20 MB of space after 100 MiB in a file.

## Name

`fallocate` — preallocate or deallocate space to a file.

## Synopsis

shell
fallocate [-c|-p|-z] [-o offset] -l length [-n] filename
fallocate -d [-o offset] [-l length] filename
fallocate -x [-o offset] -l length filename
## Options

### Core Options

- `-l, --length length` — Specifies the length of the range, in bytes. May be suffixed with KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB (or abbreviate as K, M, G, etc.) or KB, MB, GB, etc.
- `-o, --offset offset` — Specifies the beginning offset of the range, in bytes. Same suffix rules as length.

### Deallocation Operations (mutually exclusive with each other and with --zero-range)

- `-c, --collapse-range` — Removes a byte range from a file without leaving a hole. The file becomes `length` bytes smaller. Requires `offset` and `length`; `--keep-size` may not be used. Supported since Linux 3.15 on ext4 (extent-based files) and XFS.
- `-p, --punch-hole` — Deallocates space (creates a hole) in the byte range. Partial blocks are zeroed, whole blocks removed. Implies `--keep-size`. Supported on XFS (2.6.38+), ext4 (3.0+), Btrfs (3.7+), tmpfs (3.5+), gfs2 (4.16+).
- `-d, --dig-holes` — Detect and dig holes in the file, making it sparse in-place. Implies `--keep-size`. If no range specified, analyzes entire file. Minimum hole size depends on filesystem I/O block size (usually 4096 bytes).
- `-i, --insert-range` — Insert a hole of `length` bytes at `offset`, shifting existing data.

### Zeroing and Allocation

- `-z, --zero-range` — Zeroes space in the byte range. Blocks are preallocated for regions spanning holes. Subsequent reads return zeroes. Preferentially converts range into unwritten extents. `--keep-size` can be used to prevent file length modification. Supported since Linux 3.14 on ext4 (extent-based) and XFS.
- `-x, --posix` — Enable POSIX operation mode. Allocation always completes but may take longer if fast allocation is not supported.
- `-n, --keep-size` — Do not modify the apparent length of the file. May allocate blocks past EOF; can be removed with `truncate`.

### Miscellaneous

- `-v, --verbose` — Enable verbose output.
- `-V, --version` — Display version information and exit.
- `-h, --help` — Display help text and exit.

## Examples

Reserve a file taking up 700 MiB of disk space:

shell
fallocate -l 700M path/to/file
Shrink an already allocated file by 200 MB (collapse range):

shell
fallocate -c -l 200MB path/to/file
Shrink 20 MB of space after 100 MiB in a file:

shell
fallocate -c -o 100M -l 20M path/to/file
## See Also

- [truncate(1)](https://www.chedong.com/phpMan.php/man/truncate/1/markdown)
- [fallocate(2)](https://www.chedong.com/phpMan.php/man/fallocate/2/markdown)
- [posix_fallocate(3)](https://www.chedong.com/phpMan.php/man/fallocate/3/markdown)

## Exit Codes

- `0` — Success
- `1` — Failure