how can I increase my RAM size with a swap partition?
Solution 1
In a default Ubuntu installation you will always have a swap partition which will be created by the installer. In your setup it is the partition /sda5
but this location may change from system to system.
This partition will obviously not be able to increase the physical RAM but it is storage memory on your hard disk reserved for the kernel to use whenever we run short of physical RAM. This may never happen on a system with 2 GB of RAM unless we perform very memory demanding tasks (e.g. video processing, huge image processing) or have many applications running simultaneously.
Note that memory usage on swap is extremely slow, so we do not really want to have that other than in emergency situations.
In case you need a larger swap you can do so after installation either by creating a larger swap partition:
or by adding a swap on a file (which can not be used for hibernation):
More about swap can also be found here:
- Why is swap being used even though I have plenty of free RAM?
- How do I configure swappiness?
- I have 16GB RAM. Do I need 32GB swap?
Solution 2
You've piece of (hardware) RAM of 2GB and you can't 'create' more RAM with software. But I think I know what you've heard of.
From Linux.com
When the system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current application (process) that needs the memory immediately.
So when you have a SWAP space that is twice as big as your memory (in your case a swap space of 4 GB) your system will be able to putt the entire memory on swap space, and read the other 2 GB in on the memory. In other words, it is able to swap the entire content of your memory with the 2GB data on the swap disk.
Related videos on Youtube
Narasimha Reddy.P
Updated on September 18, 2022Comments
-
Narasimha Reddy.P over 1 year
Presently my RAM is 2GB. I heard that in linux we can get extra memory to RAM from the harddisk by using swap partition. What is the procedure for that?
here in the pics i'm giving my system info.
-
Dillmo over 10 yearsThe swap partition is not meant to act as RAM, since any memory stored on the hard disk is very slow. However, it is necessary to have a swap partition in case the RAM overflows. That way, it would catch the overflowed RAM, preventing a crash.
-
falconer over 10 yearsThe guys below answered your question. I just want to suggest you to don't use a 64 bit system with only 2GB RAM. It is inefficient with that few RAM, stick with a 32 bit OS and you will have more free RAM.
-
psusi over 10 yearsYou already have a swap partition as one is set up by the installer, and you see it shown by
swapon -s
.
-