Emergency Swapfile: when your memory fills up

FAIL (the browser should render some flash content, not this).

How to make a swapfile when you run out of memory.

Download in .ogv format


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Linux can handle more than 1 swap space

mogwai's picture

See here about multiple swap spaces and how to manage their priority.

swapfile initialization takes long time

Artem's picture


So I created a swap file of 16GB in an ext3 file systems, but it took several hours to complete swapon. And this happens every time the machine reboots. IS there a way to speed up this process?


Swap FILES tend to be slow. Try a swap partition instead.

Silver Knight's picture

The original post is about swap files rather than swap partitions. Both are used for the same purpose, but as stated in the post title "Emergency Swapfile", swap files tend to be best used for emergency situations or specialty needs (for example, when partitioning the drive is not possible for one reason or another). If you ARE able to re-partition the drive space, then far more efficient performance-wise is the swap partition (or even better yet, a swap DRIVE if you have a speedy but small-ish spare drive laying about somewhere). This will surely give much better performance than using a swap file, especially when dealing with sizes in the multi-gigabyte ranges. Of course, as the other reply to this post states, you should also consider carefully the size of your required swap space as well. 16 gigabytes does seem a bit extreme unless you are using insane amounts of RAM for some really intense application.

> far more efficient

Anonymous's picture

> far more efficient performance-wise is the swap partition

Mainly untrue. See Andrew Morton in

RE: 16Gb Swap File

jacksinn's picture

Unless you are running on 4GB of RAM or more, I'd suggest going with a lower swap size. I like to keep mine about twice the size of the amount of RAM I have. General practice usually ranges from 1x-4x the size of your RAM.