Can a RAM disk replace a swap partition?

Q I'm trying to perform an experiment on my Fedora box, to set up a RAM disk to use as a swap device to replace the swap partition. There seems to be some debate over whether there's any point to this so I thought that I'd set it up and test the performance with a few games of Doom 3. Can someone explain how I might go about this?

A We've been trying to figure out why you would want to do this, but we really have no idea. It's easy enough to build a RAM disk, then install a swap filesystem on the block device. You can make a swap filesystem on the RAM device, assuming it's compiled into the kernel, with:

# mkswap /dev/ram0
# swapoff -a
# swapon /dev/ram0

You can monitor the use of the swap device with 'free', and the actual paging with 'vmstat' as you're doing your testing. We'd be very interested to see what results you get from your testing, though, because we don't think that anything exciting is going to happen at all!

Follow us on or Twitter

Username:   Password: