# Using a swap file and swap partition on same disk.



## atarahas (Apr 21, 2010)

I have attempted to install a swap file on the same disk that has a swap partition. However, this leads to severe thrashing and performance degradation. However it is desirable to have both a swap file and a swap partitition on the disk, as the swap partition is somewhat inadequate so sometimes an additional swap file is nice to be added, but we still want to use the space that has been allocated for the swap partition. There is no reason why we should not get good performance with such. FreeBSD needs to make sure performance is good in this situation. This is important for useability. The system should work well in ways that users need to use it.


----------



## sossego (Apr 22, 2010)

Why not create a second swap partition?
Another, I've seen swap assigned to /var and added to /etc/fstab. Did you create a script to run it at boot?
Only when I was doing heavy graphic rendering did I use all of my swap.


----------



## phoenix (Apr 22, 2010)

The kernel stripes access across swap devices, in effect turning all swap files/partitions into a RAID0.  You should only have 1 swap device per block device, for this reason.


----------



## atarahas (Apr 22, 2010)

OK, the reason this is important is that I do not have enough room for a new partition. So i need to make a swap file inside the filesystem. I want to keep on using the swap partition. Maybe the code should be changed so there is no striping between two swaps on the same disk, if that is what is causing the bad performance?


----------



## phoenix (Apr 22, 2010)

Or, just remove the swap partition, and use the swap file.  Problem solved.


----------

