2

I wasn't exactly sure so I created a swap partition 4100MB in size. Now I have swappiness at 0 and it's highly unlikely I'll ever need swap because I don't use any memory intensive apps. I also don't hibernate. My SSD is large enough at 256GB but not huge with half of it used by Win 8.1. Should I shrink swap and if yes to what size or should I get rid of it altogether.

2 Answers 2

1

4GB RAM isn't that much actually, if you run chrome or firefox and you have multiple tabs opened for a while you can get to 4GB usage quite quickly.

You can monitor your ram usage with the "System Monitor" application. If you find that you never really exceed 4GB and your swap remains empty you might consider shrinking it. I wouldn't recommend getting rid of it altogether, since Ubuntu will randomly close applications if you run out of RAM and you have no swap.

I have installed myself a little indicator which always shows me how much RAM i use, which I find quite handy. You can find the instructions how to install it in this post: https://askubuntu.com/a/40019/255967

1

No specific rule for the optimum size of a swap partition exists. If it did, we'd all be using it and installers would offer to set things up automatically.

If a machine has no swap partition and the amount of code and data that attempts to be loaded into memory exceeds the size of that memory , there's a very good chance that things will just stop until the user manages to close something. If the machine does have a swap partition, chuncks of code and data will be written and read to and from the swap file until the demand on RAM decreases.

Adjusting the size of the partition may affect the number of disk accesses, but it can't work magic. Writing to and reading from a drive is orders of magnitude slower than shuffling bits around in RAM.

Red hat recommends setting as follows for RHEL 5:

The reality is the amount of swap space a system needs is not really a function of the amount of RAM it has but rather the memory workload that is running on that system. A Red Hat Enterprise Linux 5 system will run just fine with no swap space at all as long as the sum of anonymous memory and system V shared memory is less than about 3/4 the amount of RAM. In this case the system will simply lock the anonymous and system V shared memory into RAM and use the remaining RAM for caching file system data so when memory is exhausted the kernel only reclaims pagecache memory.

Considering that 1) At installation time when configuring the swap space there is no easy way to predetermine the memory a workload will require, and 2) The more RAM a system has the less swap space it typically needs, a better swap space

Conclusion

If Linux kernel is going to use more than 2GiB swap space at a time, all users will feel the heat. Either, you get more RAM (recommend) and move to faster storage to improve disk I/O. There are no rules, each setup and configuration is unique. Adjust values as per your requirements. Select amount of swap that is right for you. Install from the Ubuntu software center> Gnome system monitor. Select tab where it say\ Resources . See where you have swap > You can monitor this when you have a lots of applications or huge work load on your CPU to see if or when it is time to increase swap size. I personally have as much swap as i have RAM for specially when you have many app's open your system will be slow. Specially when you play online games or in general game playing.

If you wanna adjust your swap depends on if you encrypted the disk or not in your initial installation. Type Gparted in terminal ctrl+alt+T if it is missing you can install it from the software center and run it to increase swap.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .