CREATE A SWAP UNIT FROM A FILE IN DEEPIN

The exchange area (swap) is the part of the hard disk space that is used as a complement to RAM memory with limited space. This gives the operating system the feeling of having more RAM than it actually does. It is a dedicated partition on the hard drive normally created during the installation of the operating system. It is good if you create a swap area twice the size of the RAM.

As we know, there are often many Windows users who migrate to Linux. There are users who have never had contact with any GNU Linux distribution, and in the installation process they do not know both how to partition in a way that the system has a correct performance, as well as what the unit is for swap. I remember that the first time I saw it, I didn't even know what it was for, and after they explained it to me I thought it was unnecessary to create it because I thought my PC with 4GB of RAM was enough, and I didn't know the advantages it provides.

Some users may not create it at the beginning of the installation process, so by following this tutorial they would have the opportunity to create a drive Swapat a specific time according to your needs, and even if it does not meet your needs later, you can modify it.

It is explained below how to create a unit swap from a file, which will be on the hard drive.

Procedure

Memory capacity or existence is checked swap. In my case it is already assigned, because I created it using this method. The following command is executed as user root:

du -hsc swap

We already have the file ready. Now we proceed to create the unit swap, with the following command:

mkswap swap

Where "swap" is the file created a moment ago. A "UUID" will be generated for which it will take it as a disk.

Drive is activated swap with the following command:

swapon swap

Then we check that the unit is already assigned swap:

free -m

At this point, you can check the results of the previous actions through the system monitor.

Now we go on to configure so that the unit can be used swap when the operating system restarts, through the following command:

echo “/swap /swap swap defaults 0 0” >> /etc/fstab

This step can be done either with the "UUID" or with the file name. I did it with the name of the file because, each identifier of the units, of course, is unique. In case the file swap does not meet the user's need, you can delete it and create a new one with greater capacity and the same name. Given the settings, only the unit would have to be activated swap created. And all the settings are kept, since the file name is used, and not the “UUID”. This recommendation is to make the job easier. We verify through the command:

cat /etc/fstab

where the following is displayed on the last line:

After the previous step is done, the system restarts. Once logged in, you can check the allocated swap memory in the system monitor or, through the command:

free -m

And that's all for this tutorial, I hope it will be helpful to you and if you have questions or comments, do not hesitate to expose them here. Until next time.

4.9 18 votes
Rate the Article
 
Subscribe
Report of
15 Reacciones
More popular
Newer Older
Opinion from the article
See all comments
Эли
Эли (@eli)
Admin
16 días atrás

Very good collaboration Kevin Cogle, thanks for sharing with all of us.

Emiliano Masochi
Emiliano Masochi (@emilianomasochi)
16 días atrás

Muy interesante,Gracias!!! pero tengo varias dudas: Donde quedaría ubicada la partición creada dentro del HD?
I do not know Deepin but all Linux that I have installed, creates a Swap partition necessarily during the installation process, so I do not know in which case it could create it with the system already installed. In this case, what if I already have a Swap partition created?

Emiliano Masochi
Emiliano Masochi (@emilianomasochi)
Respondiendo a  Kevin Cogle
12 días atrás

Even more interesting !!!! Thanks for the reply.

DarioAR
DarioAR (@darioar)
16 días atrás

How interesting, no idea that this could be done, it may help me on my old PC that I also have Deepin there, thanks colleagues.

LeviB
LeviB (@levib)
16 días atrás

Good all the information, excellent.

Arceli
Arceli (@arceli)
15 días atrás

Excellent help material, thank you.

Antonio Oropeza
Antonio Oropeza (@oropeza2007)
14 días atrás

In my case I believe it when I install deepin, a question, is it better to change it to this method or better to leave it with what is already there? any advantage of this method? thanks.

Yarecco Jr.
Yarecco Jr. (@yareccojr)
14 días atrás

For those who have a lot of RAM (8 or 16GB) and don't want to kill SSD with SWAP or other caches I reconmend to add
tmpfs / tmp tmpfs defaults, size = xxxxM, noatime, mode = 1777 0 0
to your / etc / fstab file instead od swap
where you can replace xxxx with desired amount of memory
The system will get the speed and save SSD
and will clear all trash caches at every reboot

JulioPerfecto
JulioPerfecto (@julioperfecto)
14 días atrás

Very useful, thanks.

Jose David Escalante
Jose David Escalante (@josedavidescalante)
12 días atrás

-Excellent contribution, I understand that some distributions have already put aside creating a partition for the swap and use this method but you have to keep some things in mind that although I am a beginner as many I had already read them before.

  • if you did the normal installation you should already have the swap partition configured
  • If you have between 8 and 16 GB of ram memory and you do not have it created, it should not be necessary except in very specific cases.
  • si tienes disco ssd debes tener en cuenta que esto con el tiempo genera un poco mas des desgaste en este tipo de discos.

Additionally, recently I tried to install deepin manually on a laptop and it would not let me mount the partitions to my liking because I wanted to keep windows and it was not possible. in the end I take windows ahead.

Manuel Enrique Mariani Torres
Manuel Enrique Mariani Torres (@manuelenriquemarianitorres)
9 días atrás

Very good help friend Kevin

ErnestoRyes
ErnestoRyes (@ernestoryes)
4 días atrás

Very good advice for those of us with little memory as a team. thanks

15
0
We would like to know what you think, join the discussion.x
()
x