I'm wondering what the difference is between creating a swapfile with
fallocate -l 1G /swapfile
and
dd if=/dev/zero of=/swapfile bs=1024 count=1024
both seem to work fine, but does one have an advantage over the other?
The only thing I could find online was that fallocate
does not work on all file systems.
From the
mkswap
manpage:And from the
swapon
manpage:It follows that, while
fallocate
may be faster thandd
, it's not suitable for creating swap files and not supported by swap-related tools.Fallocate is faster, From the fallocate manpage: