JayAtjeu

Member
Apr 27, 2006
6
0
151
One of our clients with a dedicated system noticed today after nearly a year with the server that it doesn't have a swap partition. Now I am pretty sure that we installed it with a partition so my intuition tells me that this is a recent developement because he should be seeing a lot more load problems if he had no swap partition before now I think. At any rate can anyone think of what might cause the swap partition to dissappear. I'm not talking just about it being unmounted either, as it doesn't even register the /dev/sda3 partition in fdisk -l

Here's the listing out of top so you see what I mean:
Mem: 2074892k total, 1747268k used, 327624k free, 60540k buffers
Swap: 0k total, 0k used, 0k free, 1040040k cached

here's fdisk -l:
root [~]# fdisk -l

Disk /dev/sda: 300.0 GB, 300090728448 bytes
255 heads, 63 sectors/track, 36483 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 36483 292945275 fd Linux raid autodetect

Disk /dev/sdb: 300.0 GB, 300090728448 bytes
255 heads, 63 sectors/track, 36483 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 36470 292945243+ fd Linux raid autodetect

Disk /dev/md0: 299.9 GB, 299975835648 bytes
2 heads, 4 sectors/track, 73236288 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table


So if you know a way to create a partition for swap after the fact or know of anyway to that it could have dissappeared I'd appreciate the assistance.

I should also add that he said he upgraded the kernel recently to 2.6.9-42.0.2ELsmp, might that effect this?
 

ujr

Well-Known Member
Mar 19, 2004
290
0
166
I dont know why I stumbled on this but here is the delayed answer (albeit 2 months later):

mkswap -f /dev/hdaX
swapon /dev/hdaX

then add it to fstab:

/dev/hdaX swap swap defaults 0 0

hdaX would be your drive partition for the swap. You may want to note that you can place it on a second drive to ... ie hdbX. Sometimes placing the swap on the outer frindges of the drive will also inprove performance.

If you don't have a partition made for it, you may need to repartition your drives.

However, you can also do this, if you are in need of a file-based swap. This is a really good solution if you are also out of swap drive space:

dd if=/dev/zero of=/var/fileswap bs=1024 count=65536

this 65536 size is 64MB, alternatively for even larger, just multiply the MB x 1024 and use that.

then, you will need to mount your new fileswap like so:

mkswap -f /var/fileswap
swapon /var/fileswap

and to remove it in the future use swapoff command then rm the file.

Hope this helps you or anyone else ;)