Control Web Panel
WebPanel => How to => Topic started by: Administrator on September 17, 2014, 11:31:53 AM
-
Check for Swap Space
Before we proceed to set up a swap file, we need to check if any swap files have been enabled by looking at the summary of swap usage.
swapon -s
If nothing is returned, the summary is empty and no swap file exists.
Check Disk Space Usage
After we know that we do not have a swap file enabled, we can check how much space we have on the server with the df -h command.
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda2 20G 7.0G 12G 39% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/vda1 504M 38M 441M 8% /boot
Create and Enable Swap (512k = 512 MB)
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
sudo mkswap /swapfile
sudo swapon /swapfile
Now you can see your swap using command
free -m
This file will last on the server until the machine reboots. You can ensure that the swap is permanent by adding it to the /etc/fstab file.
sudo nano /etc/fstab
Paste in the following line:
/swapfile swap swap defaults 0 0
To prevent the file from being world-readable, you should set up the correct permissions on the swap file:
chown root:root /swapfile
chmod 0600 /swapfile
-
Hi, I have followed your steps and created a 2 GB SWAP FILE. But when I open the CWP dashboard, I dont see swap activated. However if I visit Disk Quota in Server settings, in the "Your disk status from the file /etc/fstab" section, it shows the swap file present but in partition scheme, it doesnt.
Even when I run df -h in terminal, I dont see the swap activated.
If I try to run swapon /swapfile it says
swapon: /swapfile: swapon failed: Device or resource busy
If I execute free -m it shows Mem and Swap but the swap is 100% free
If I execute swapon -s it shows the /swapfile entry with 0 as a value in Used field and -2 in the priority field
How to know swap is working and how to show it in the dashboard also?