# fallocate usage
###### tags: `linux`
To quickly create a large file which "real" allocate blocks (pre-allocate), fallocate command is much faster. use of "dd" or "cp" are too slow because they take time to "real" write data.
This is useful for testing disk usage for monitoring or trigger storage full error.
create 1G file
```
$ fallocate -l 1G 1Gfile.img
$ ls -l --block-size=M ./1Gfile.img
-rw-rw-r-- 1 ycheng ycheng 1024M May 29 23:24 ./1Gfile.img
```
reduce size by choping data with offset and length, Example:
```
$ fallocate -c -o 800M -l 100M ./1Gfile.img
$ ls -l --block-size=M ./1Gfile.img
-rw-rw-r-- 1 ycheng ycheng 924M May 29 23:25 ./1Gfile.img
```
#### Reference
https://man7.org/linux/man-pages/man1/fallocate.1.html