Enter your email address:

Delivered by FeedBurner

swap partition vs swap file

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

Share/Save
 #

While enhancements have been made in the 2.6 kernel and speed of both has become very close, there will always be a bit of filesystem overhead if swapping to a file contained inside of a filesystem. If you want optimal performance (and what is that, really?... swapping is slow, period. Increase RAM so that you don't swap for _best_ performance), you would want to use a partition. You could also try putting swap on an LVM logical volume (assuming the lvm overhead < filesystem overhead) to get the resizability you sought as well as increased performance.

 

If this was useful for you, please consider making a donation, any amount is welcome, please proceed by clicking on the yellow donate button, thank you in advance.

Navigation

Recent comments