Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
fallocate -l 1G FILE creates a 1 GiB file in a moment: the file system reserves the blocks without writing zeros. Great for test files and disk-full tests. Other modes remove ranges (punch holes) or find and free zero blocks (-d).
Zo schrijf je het
fallocate [-c|-p|-z] [-o OFFSET] -l LENGTH [-n] FILE
fallocate -d [-o OFFSET] [-l LENGTH] FILE
fallocate -x [-o OFFSET] -l LENGTH FILEOpties 12
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Create a 1 GiB file at once
fallocate -l 1G /var/tmp/test.img ls -lh /var/tmp/test.imgDone in milliseconds.
2Fill a disk for a test
fallocate -l 9G /data/fillTest alerts and app behaviour on a full disk; delete it after.
3Make a sparse file smaller on disk
fallocate -d disk.imgZero blocks are freed (VM images, backups).
4Free a range in a log file
fallocate -p -o 0 -l 100M big.logThe file keeps its size, uses less disk.
5Reserve space without changing the size
fallocate -n -l 500M db.datSpace is reserved for later writes.
6Compare used and visible size
After -d the real use is smaller.
7Swap file (careful)
fallocate -l 1G /swapfileWorks on many file systems, but swapon may refuse it; dd is the safe way.
8Test file for upload limits
fallocate -l 101M /tmp/too-big.binTest a 100 MB upload limit of a web app.
9Truncate is different
truncate -s 1G sparse.imgtruncate makes a sparse file (no blocks reserved).
10Check quota limits
fallocate -l 2G ~/quota-testFails with "Disk quota exceeded" when the limit is lower.
Niets past bij dit filter.
Exitcodes
0 :: Done. 1 :: Error.