4

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?

6

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:

| improve this answer | |
  • I have been through the links. And I didn't created 2 files, I just followed the instructions that were given in link i mentioned. Even if i check sudo swapon -s, I see Filename: /swapfile Type: file Size:4194300 Used:52736 Priority:-1. I don't see 2 swapfiles or swapportion. Also, how can I be sure which one should i delete and which I should keep. – Prashant Prabhakar Singh Oct 19 '16 at 5:40
  • From your output above, you can delete the second file swapspace because this file is unused. – Benny Oct 19 '16 at 6:42
2

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 manager

I 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) ...
| improve this answer | |
  • I just deleted the swapspace file manually, I changed it's permissions and used rm -rf swapspace. Hopefully,I did't removed it in wrong way. After restarting my memory was free by 4Gb. ANd now if I check dpkg -l swapspace , I see : dpkg-query: no packages found matching swapspace – Prashant Prabhakar Singh Oct 19 '16 at 6:44
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     -2

You 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.