Ubuntu – How to make swap space?

swap

I'm very new to Ubuntu, using 14.04. I need to make swap space, so I read, to overcome a garbage collector problem. My RAM is 8 GB, and my code is using big data and uses a lot of RAM.

What is swap space? Does it mean using flash memory or is it a way to use the RAM of the laptop? What should I do (from scratch)?

command lsblk gave

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk 
├─sda1   8:1    0 461.9G  0 part /
├─sda2   8:2    0     1K  0 part 
└─sda5   8:5    0   3.9G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom 

command free-h gave

        total        used  free  shared  buffers  cached
Mem:      7.6G       7.4G  163M   727M   196M     4.9G
-/+ buffers/cache:   2.3G  5.2G
Swap:      9.9G       0B   9.9G

swapon -s gave me

Filename                Type        Size    Used    Priority
/dev/sda5               partition   4086780     0       -1
/swapfile               file        6291452     0       -2

blkid gave me

/dev/sda1: UUID="bf8fe3ec-1937-458f-be1e-5e1270111217" TYPE="ext4" 
/dev/sda5: UUID="2336032a-d853-4d38-9b2c-c24793586d3c" TYPE="swap"

gparted

Best Answer

Memory is divided into "pages". when memory fills the system will write some idle pages to disk so that it can use active memory for other programs, this is called paging.

Swap Space is the disk area the system uses for paging. on some systems it is a file. Ubuntu and other linux/unix system use a drive partition for swap space. While a swapfile can grow as needed, it is subject to fragmentation. Since memory pages are all the same size, a swap partition does not have fragmentation issues but is limited to the size of the partition made for it.

Swap space is also used for hibernation. Thus it is recommended that swap space be at least twice the size of your installed memory.

If you can post a screen shot of your partitioning information, I can give more dtailed instructions on adding space if you need to