Comments on: How to Extend Swap Space using Swap file in Linux https://www.linuxtechi.com/extend-swap-space-using-swap-file-in-linux/ Sun, 16 Oct 2022 19:39:07 +0000 hourly 1 By: Jonathan https://www.linuxtechi.com/extend-swap-space-using-swap-file-in-linux/#comment-42845 Sun, 16 Oct 2022 19:39:07 +0000 http://www.linuxtechi.com/?p=3147#comment-42845 The mkswap manpage has a warning NOT to use fallocate on most systems:

“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. “

]]>
By: netdragon https://www.linuxtechi.com/extend-swap-space-using-swap-file-in-linux/#comment-17928 Sat, 14 Dec 2019 13:27:05 +0000 http://www.linuxtechi.com/?p=3147#comment-17928 Use fallocate, not dd, for creating /swap_file . It’s faster and doesn’t require an enormous memory buffer.
sudo fallocate -l 4G /swap_file

]]>