← 返回命令列表

Linux command

fallocate 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Allocate

fallocate -l 700M path/to/file

Shrink

fallocate -c -l 200M path/to/file

Example

fallocate -c -o 100M -l 20M path/to/file

说明

fallocate preallocates or deallocates space to a file. Unlike writing zeros, fallocate uses filesystem-specific operations to quickly allocate space without initializing the data, making it very fast for creating large files.

参数

-l, --length _size_
Length of the range to allocate or deallocate
-o, --offset _offset_
Offset of the range from the beginning of the file
-c, --collapse-range
Remove a range from the file without leaving a hole
-d, --dig-holes
Detect and convert zero blocks to holes
-p, --punch-hole
Deallocate space (create a hole) in the file
-z, --zero-range
Zero a range but keep space allocated
-n, --keep-size
Maintain apparent file size when extending allocation

FAQ

What is the fallocate command used for?

fallocate preallocates or deallocates space to a file. Unlike writing zeros, fallocate uses filesystem-specific operations to quickly allocate space without initializing the data, making it very fast for creating large files.

How do I run a basic fallocate example?

Run `fallocate -l 700M path/to/file` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -l, --length _size_ do in fallocate?

Length of the range to allocate or deallocate