I have made a swapfile following How to add swap space on ubuntu 16.04. And I have 4GB swap memory available. But in my root directory I see 2 file with names swapfile and swapspace , both occupying 4.3GB of space. I don't understand why 2 files are there. I guess there should be a swapfile but what is this swapsapce then?
3 Answers
You have 2 files probably because you created 2 files.
You can have a swap partition(recommended) or a swap file, or a combination of swap partitions and swap files.
Here you can get some more info:
- Swap Partition VS File For Performance
- Ubuntu SwapFaq
- Wikipedia Paging Article
- All About Linux Swap Space
Do you have a program called swapspace installed?
# dpkg -l swapspace
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-========================-=================-=================-===============
ii swapspace 1.10-4ubuntu3 amd64 dynamic swap space managerI see from the man page swapspace(1) that the default location for a swap file made by swapspace is /var/lib/swapspace, but the -s option lets you put it anywhere.
As long as swapon -s only shows that /swapfile is in use then the file /swapspace is not.
And if you have swapspace installed, and don't intend to use it, it should be safe to remove it with apt-get remove:
# apt-get remove swapspace
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED swapspace
0 to upgrade, 0 to newly install, 1 to remove and 5 not to upgrade.
After this operation, 122 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 139800 files and directories currently installed.)
Removing swapspace (1.10-4ubuntu3) ...
Processing triggers for man-db (2.7.5-1) ... 1 Try running swapon -s as root. This will show you what swap is being used, and whether its a partition on a disk or a swapfile on a filesystem.
A 4GB swap partition as primary, and a 1GB swap file in /mythtv1/ as last resort.
backend:~# swapon -s Filename Type Size Used Priority /dev/dm-4 partition 4194300 178756 -1 /myth1/swapfile file 1048572 512 -2You can have multiple swapfiles and swap partitions, with equal or different priorities. That is, you may choose to swap to two swap files, one on each of two fast hard drives, and have a third swap file with a lower priority as a backstop on a slower drive.
Effectively swapfiles and swap partitions function the same, its a matter of convenience which you choose.
Swapfiles don't need backing up, but they should have permissions to stop anyone but root reading it.