[TUTORIAL] How to manually create swap memory space

If you have this problem:

You can solve with the next step by step…


Step 1 – Login as the Root User

su -
or
sudo -s

Step 2 – Create Storage File

dd if=/dev/zero of=/cyberpanel.swap bs=1024 count=1048576

Step 3 – Secure swap file

chown root:root /cyberpanel.swap && chmod 0600 /cyberpanel.swap

Step 4 – Set up a Linux swap area

mkswap /cyberpanel.swap

Step 5 – Enabling the swap file

swapon /cyberpanel.swap

Step 6 – Update /etc/fstab file

To activate /cyberpanel.swap after Linux system reboot, add entry to /etc/fstab file. Open this file using a text editor such as nano.

nano /etc/fstab

add…

/cyberpanel.swap swap swap sw 0 0

As shown here:

image

How do I verify Linux swap file is activated or not?

Simply use the free command:

free -m

How can I display swap usage summary on Linux?

Type the following swapon command:

swapon -s

Once this is done, the swap memory space will be added correctly:

1 Like