Quote |
Swap files Swapping to files is usually slower than swapping to a raw partition, so this is not the recommended permanent swapping technique. Creating a swap file, however, can be a quick fix if you temporarily need more swap space. You can have up to 8 swap files, each with size of up to 16 MB. Here are the steps for making a swap file: - Create a file with the size of your swap file: dd if=/dev/zero of=/swapfile bs=1024 count=8192 This physically creates the swap file /swapfile, the block size is 1024 bytes, the file contains 8192 blocks, the total size is about 8 MB. [The dd command copies files. In the example above, the input file (if) was /dev/zero, the output file (of) was /swapfile . You cannot use the cp (copy) command for creating a swap file because the swap file must be physically continuous on the hard drive.] - Set up the file with the command: mkswap /swapfile 8192 - Force writing the buffer cache to disk by issuing the command: sync - Enable the swap with the command: swapon /swapfile When you are done using the swap file, you can turn it off and remove: swapoff /swapfile rm /swapfile |