Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OK, here's what's going on.

I've got a RedHat 5 server with a swap partition (/dev/sda3) that's 3GB.

For some reason swap memory is still being taken up on / (/dev/sda2), and fills up the drive on occasion. Is there a way I can tell my system that if it needs to use HD space for swap, to use a different drive?

share|improve this question
Are you sure that swap is filling up /, and not temporary files (or log files, or something else)? – mattdm Apr 7 '11 at 15:40
up vote 3 down vote accepted

To find really what is using your space, use df to see the partition layout and disk usage, and du / -h --max-depth=1 to get an estimative of directory sizes and from that see what is happening.

Also, swapon -s will show exactly what swap devices are being used and how much of each one is occupied.

share|improve this answer
I've done searches for large files, tmp files, and even moved some larger stuff off the partition to another one. Space keeps filling up. After a fresh reboot I get the space back, then it fills up again eventually. – rkalajian Apr 7 '11 at 15:15
@rkalajian That sounds like /tmp or some kind of logfile, not swap. Do you have tmpfs or ramfs? Add the output of your df to your question. – coredump Apr 7 '11 at 15:17
@coredump Logs are on a seperate partition, and /tmp is clean. 'df' shows: /dev/sda2,2972268,1933592,885256,69% / - /dev/sda,131581128,33872852,90916400,28%,r5 - /dev/sdb1,481711200,142404696,314442304,32%,/data2 - tmpfs,4155412,0,4155412,0%,/dev/shm – rkalajian Apr 7 '11 at 15:21
Yeah that output shows nothing really wrong. See if free is showing your swap enabled. – coredump Apr 7 '11 at 15:27
You can also use files; you don't have to use partitions, and you don't have to use something like swapd to do so. – mattdm Apr 7 '11 at 15:37

Ignoring all the parts of your question that make no sense, you can use mkswap to format a device to use as swap, and you can use swapon to activate it. Add it to /etc/fstab if you want to make it permanent.

share|improve this answer
I've already got a swap device, and no means to add a new device for additional swap space right now. I'm looking into creating a swap file on an additional partition, but I need to know it'll take precedence over filling up / when the actual swap drive overflows. – rkalajian Apr 7 '11 at 15:26
@rkalajian — look at man swapon for how to set the relative priority of your swap devices. (This can go in fstab, too.) – mattdm Apr 7 '11 at 15:39
@mattdm - That sounds like exactly what I need. – rkalajian Apr 7 '11 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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