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?
To find really what is using your space, use
df
to see the partition layout and disk usage, anddu / -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.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 useswapon
to activate it. Add it to/etc/fstab
if you want to make it permanent.You can simply follow the below steps to create a additional swap partition on Linux.
Just create a partition with
fdisk
command and change it's partition code for Linux swap partition e.g.82
.now use command
mkswap drive_name
to create the swap signature, then useswapon drive name
command to activate the swap partition.For example, to create swap partition type:
and to activate it
Note : I have mentioned
/dev/sdb1
for example purposes, you use the drive as per your scenario.now mount the created swap partition on
/etc/fstab
file.for testing you can use below commands :-
swapon -s
shows swap usage summary by devicefree -m
Display amount of free and used memory in the system