Are there any conventions on where to put swap files on Linux?

I usually just create them in /var/swapfile, but that seems a bit too high up in the hierarchy.

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

AFAIK there is no location defined in the File System Hierarchy Standard.

Because /var is for often-changed files, I would say it is okay to place it here. But remember that if you use a flat-file swap instead of a partition, consider to use a fast file system for /var.

link|improve this answer
feedback

The conventional way is to have a partition dedicated to swap. If you use a file it's at your own discretion, but Malte's suggestion of the file system being important is a good one.

link|improve this answer
+1 for it's own partition. I usually have swap as a partition at the beginning of the drive. /boot then swap is my general approach. – egorgry Jun 10 '11 at 18:30
I personally don't really care about the last few percentage points of swap performance enough to take the extra complexity of a separate partition. If my server starts seriously swapping, I have a problem anyway. The swap space is more of a last-resort safety net in case some process starts gobbling up memory. – Jo Liss Jun 11 '11 at 14:10
That's fine, you're welcome to use a file. I find partitions quite easy to manage but I see your reasoning. You just asked what the convention was and that's pretty much the default scenario. – Caleb Jun 11 '11 at 14:18
@egorgry - Didn't BSD historically try and always put swap on the 2nd partition to be in the middle? – Xepoch Mar 1 at 17:52
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.