Adding SWAP in CentOS 7

For the dedicated server, I chose CentOS only because the BrainyCP control panel works on it, which I more than liked after suffering with VestaCP.

One of the biggest problems when working with hosting and site building was that the "Orthodox" methods of installing the core and all modules on Drupal 8 were closely related to using the SSH compser. Moreover, if the project jump was still somehow carried out, then the installation of the modules simply did not drag on, on ordinary hosting with 2 GB of RAM. It would be possible, of course, to cough up and take a tariff more expensive and with more bold parameters, but for initial use, you can try to expose the SWAP swap partition, which can help in the lack of memory of the gluttonous composer.

Below, I want to share a small instruction, based on an article from the linux-notes.org site, which helped out a lot in its time.

Just want to make a reservation that usually there is no swap partition on a freshly installed linux, but you still need to check. We will execute all commands as root. The simplest command is free -m. It will show how much space is available to us, and in particular the swap section, which I have already created. If you do not have this section, then on the contrary there will be only zeroes

But that's not all! In this version, the swap is, but after restarting the server, you will have to mount it anew. Let's add automatic mounting.

It is necessary to register our swap in the fstab table. The vim editor was used in the original article.

sudo vim /etc/fstab

However, personally, I did it in the following way - run mc, go to the folder, select fstab and press F3 - edit.

Add an entry about our swap there

/home/swap/swap.img swap swap sw 0 0

We save. Done!

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
The comment language code.