Dari halaman mkswap
manual :
Note that a swap file must not contain any holes. Using cp(1) to
create the file is not acceptable. Neither is use of fallocate(1) on
file systems that support preallocated files, such as XFS or ext4, or
on copy-on-write filesystems like btrfs. It is recommended to use
dd(1) and /dev/zero in these cases. Please read notes from swapon(8)
before adding a swap file to copy-on-write filesystems.
Dan dari halaman swapon
manual :
You should not use swapon on a file with holes. This can be seen in
the system log as
swapon: swapfile has holes.
The swap file implementation in the kernel expects to be able to write
to the file directly, without the assistance of the filesystem. This
is a problem on preallocated files (e.g. fallocate(1)) on filesystems
like XFS or ext4, and on copy-on-write filesystems like btrfs.
Oleh karena itu, walaupun fallocate
mungkin lebih cepat daripada dd
, itu tidak cocok untuk membuat file swap dan tidak didukung oleh alat terkait swap.
fallocate
biasanya lebih cepat (karena tidak mengisi file yang dibuat dengan nol) - jika tidak ada perbedaan, hasil akhirnya sama. Lihat: antipaucity.com/2017/08/31/…