Hi, this topic is about adding or extending swap space.
Now, what exactly swap space is a swap.
So according to CentOS, dog swap space in the next is used.
When the amount of physical memory RAM is full it the system needs more memory resources and the RAM
is full.
Inactive pages and memory are moved to the swap space.
Wasswa space can help machines with a small amount of ram.
It should not be considered as a replacement for more.
RAM swap space is located on hard drives, which have a slower access time than physical memory.
So this is a very easy and straightforward definition of a swap.
In my own words, I would say every machine has a memory wide.
It comes with a memory one get ten gigabytes.
Whatever the number of memory that you have in your laptop when you run out of memory, then there is
a way that you could add a virtual memory to it, which is not like a physical, real memory.
It's a virtual memory that comes from your hard drive.
So in that virtual memory in Microsoft Windows environment is called virtual memory in an environment
is called swap.
So the recommended swap space by the operating system, it's twice the size of RAM, which means like,
let's say if you have two gig of physical memory in your system, then you should have a tug of space.
So the the idea is or the formula is, if M is less than two, by the way, M is let's let's take an
example of an equal amount of ram in gigabytes, as is the model.
So our space in gigabyte.
So F m which is the RAM is less than two gig then the size of swap, which is that the memory times
two LS swap will be memory plus two.
So that's a general rule of thumb.
The commands that we will be using to extend the swap space are Deedes to create a file make swap swap
on our swap off.
So let's do that by logging into our machine and our Linux terminal and see how this space works.
By Terminal opened the Linux console GUI.
Now before we get into a swap, I want you to undermine each command and in this command you will see
you get the entire disk space partition, right?
Your file system has a total size of 10 gig, so eight gig is assigned to route one gig is assigned
to boot.
So that is nine.
So where did the one get go?
So that one gig is actually assigned to swap space.
So that's what place.
Plus the one gig is its own physical memory.
So if you add these up for eighty four ninety six point eighty six for ninety six and these two hundred
and hundred, all of these six of them and you're going to add them, it's going to equal to two gig.
Now why to gig.
The reasons why it's two gig is because one gig is actually the physical memory.
We actually allocated a physical memory when we were actually creating the washing machine and the one
gig, a swap was automatically created when we built the Linux operating system.
So that's why we only have eight gig here left.
So when you run free minus M, that's a command.
To check how much memory we have, you will see the memory.
This is a physical memory.
We have a one gig which is estimated number of uses, 256 and freeze 81.
The swap, which was added during the installation is ten twenty three, which is also equal to one
gig.
Twenty five is used and this is a free space.
Now we are assuming here that this swap space right here and this memory, they are reaching almost
full.
They are getting full, they are all the utilization is almost 100 percent.
Now, how can we extend or add more so space?
Well, one way is that you again, if you have a physical system, you could add a new memory Dem to
your system.
A Dem is.
Actually, a physical slice of memory, so you add that to increase my memory, if it's a virtual machine,
you could actually power down your machine and increase the virtual memory.
That's perfect.
But what if you do not have those options available?
Then what you could do is you could slice some off that disk from your disk drive and use it for swap.
So let's say if I wanted to increase the size of this swap, which is one two one zero two three, and
I wanted to add another one gig to how it's going to work.
First, I have to take one gig and let's say I want to add one more game to it.
So I want to take one gig from my desk space and dedicate that to swap.
So to do that, I have to run a command deed, by the way, to run the command, I have to behold.
So become rude.
OK, now the command is Deedes space if equals sign dev zero space o f equals sign
slash and you swap.
Now this is the name that I'm picking.
You could pick any name and I'm putting it in under Slash.
So this is the name of the file.
The X means the size the bite size one mag and account equal one zero to four.
Let me explain to you this command how it works.
Most of the time you would have to write this command as is why it is written like that.
Well, that's how it is.
It is what it is.
That's what usually people say.
So to explain your deed is just a command to create a new file.
If it stands for read from five instead of standard input, which is Dev zero, you have to have this
by default of meaning's right to a file instead of standard output.
So you're going to write everything about your virtual pages in this file, be as means read and write
by types at a time.
So and the count is the total size of the file, of course.
So when you hit enter.
This should create a file with the size of one gig, so you have information coming here is records
in, records out, and the file sizes create one point, one gig, which is, of course, approximately
one gig.
So let's go to CD slash and do this myself, TIAR.
And you will see right here, this is our new file that is created.
OK, now one one thing you should be wondering, hey, why we cannot create the file just with a touch
command?
Well, that's a very good question.
We'll touch command creates an empty file.
You don't want to assign an empty file to swap, right.
You want to take away some chunk from your desk and dedicated to that swap.
And how do you do that?
You would have to use added command.
That's why you cannot use touch anyway.
So now you see this new space file has been created.
The second step is to adjust the permissions.
You don't want to allow people to read that file.
You don't want to allow others and sorry group and others to read that file.
The owner, which is rude to read and write, is OK.
So to do that you have to do change.
Mod Group and other miners are Newsworld.
Now this should take away to read and read for group and from others.
Another way you could have done is by a change mod 600 and then the name of the file which would perform
the same function anyway.
So the correct permissions have been assigned perfect.
Now to make the swap.
What do you want it to do with this file now?
It's just an empty it's just a file that that is holding a space from the disk and that space from the
disk is one gig.
So what you want to do with that?
Right.
So let's make Swap STICKMAN to do that is EMK swap space.
You swap it enter and this will tell you you're setting up swap space version one size this and that
label no label.
Use your ID and give you some information about the newsroom.
So now run free minus M to see if it's a new swap is added on was not added Y because you have to enable
or turn on the swap.
So the swap you are telling the operating system that this is a file and this file will be used for
swap.
Right.
You created a file system which is make swap, but now what do you want to do with that?
You want to give it a swap.
So type the command swap on a new swap hit enter.
And this should add the swap space to now do three minus M and you will see now the file.
The size of the swap has increased.
Before it was one zero two three and now it's two zero four seven.
If you want to have to swap space be enabled during boom time, you would have to specify the file in
V.I. in the first half file you will go into the file and then you come down all the way and put a new
line.
I put new swabbed space, the PA system time, which is swap that sorry, the where is it going to be
mounted to swap.
We now mounting it.
It's just a swap.
What type of file system is that.
It is a swap again default zero zero and escape and save the file.
Be very careful with ETSI first tab.
If you make a mistake you will.
Your system will not board up, so make sure you type in correctly.
Check it a couple of times before you go and reboot your system.
Now, you could go ahead to reboot your system and you could verify that your swap will be added again
at your boot time.
So this is how you create a swap space, try it out with different values and this will be very helpful
in corporate environment when you run out of memory.