I have been trying to find the performance differences between a swap partition and a swap file in Linux.

I have found several affirmations that swap partitions are better, but lots also say they are the same (at least for kernels 2.6).

I can find some differences that can help you make the good choice, or when to use swap on file or partition. Swap partitions can be used by two or more Linux installations on the same PC (dual boot or triple boot).

Swap partition are better in case of full disk where the swap file could be created fragmented.

On the other hand swap files are good if you need to change the size of the swap memory regularly as it is easier to resize the swap file that the whole partition, you may say you can have two swap partitions and enable or disable as you need, but you will be wasting the space of the disabled swap partition.

The swap files will work as good as the swap partitions if they are created on non-full disks to avoid fragmentation.

I may also think that one is a good complement of the other whenever you may need more swap memory, and your system is already installed, in that case you can add swap memory with swap files.

If you have any experiences on this topic please post your comments, and also read this article