0

My laptop is getting kinda slow, especially when having Firefox opened with multiple tabs, which is why I'm trying different ways to make it a little snappier. It has an Intel Core 2 Duo T5600, 2 GB of RAM, and Linux Mint installed. I've read that decreasing swappiness can help, so I set it from the default value vm.swappiness=60 down to 33. But since I'm frequently running into RAM issues and my laptop doesn't support more than 2 GB, I would like to increase the swap partition.

I worked through a whole bunch of tutorials and SE discussions, but it seems that increasing swap is not so easy in my case as the root partition already takes up all the free space:

Gnome-Disks

This is the output of lsblk:

raffy@mypc:~$ lsblk
NAME               MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                  8:0    0 238,5G  0 disk  
├─sda1               8:1    0   976M  0 part  /boot
└─sda2               8:2    0 237,5G  0 part  
  └─lvmlmde        254:0    0 237,5G  0 crypt 
    ├─lvmlmde-root 254:1    0 233,6G  0 lvm   /
    └─lvmlmde-swap 254:2    0     4G  0 lvm   [SWAP]
sr0                 11:0    1  1024M  0 rom 

For example, I tried this:

raffy@mypc:~$ sudo lvm lvresize /dev/mapper/lvmlmde-swap -L +1G
Insufficient free space: 256 extents needed, but only 0 available

This seems to make things complicated, as the root partition first needs to be reduced in size. However, I'm not really an expert in this and I'm afraid to lose data or even brick the system (which is finally running perfectly, except for the lack of RAM). Also the whole disk is encrypted.

Somewhere I remember reading that one can also just create a second swap file, but I'd rather do things "properly" (?) and increase the existing swap partition. I'm wondering though if there is any difference in speed having a swap partition vs. swap file. The good news is (I think) that I have an SSD, so the swap should be a little faster than with a standard "spinning" hard drive...

Is there a safe & clean procedure for decreasing the root partition by X and increasing the swap partition by the same amount?

PS.: This is the output of swapon:

raffy@mypc:~$ swapon -s
Filename                Type        Size    Used    Priority
/dev/dm-2               partition   4124668 11520   -2

...what does the negative priority of -2 mean, is this an error?

0

I've found that increasing swap doesn't solve speed performance issues.

Swap is useful for hibernation where your RAM can be dumped to a disk. It's also useful when you have a small amount of RAM and want to avoid crashes. When an application tries to allocate more RAM, if memory isn't available that application may crash.

On the other hand, if you need more than 2GB of memory, swap will resort to using your disk drive as additional RAM. Disks are no where near as fast as RAM and so memory access becomes very slow.

In your case, swap compensates for a lack of memory, but the cost is speed.

The solution is more RAM or a lighter desktop environment which doesn't need as much RAM.

| improve this answer | |
  • OP writes that her laptop doesn't allow more RAM – david Aug 26 at 22:59
  • She sure did. Unfortunately that's the solution, not swap. – Stewart Aug 27 at 5:35
  • True, in principle – david Aug 27 at 6:29
  • I also really like @Artem S. Tashkinov's answer. He has some other good ideas. – Stewart Aug 27 at 7:06
0

You have very little RAM and you're using the SSD as your swap partition which is not the best idea because SSDs have a limited write resource.

Considering your situation, instead of adding more SWAP I'd do the following:

  1. Replace your desktop environment with a lighter one, e.g. XFCE or even IceWM (which is basically just a window manager)

  2. Install Ublock Origin and NoScript in Firefox - that will decrease its memory use significantly. Allow JavaScript only for needed websites

  3. Try not to open many tabs in Firefox

  4. Do install and enable earlyoom

  5. Most importantly try to add physical RAM to your device.

2GB of RAM is too little nowadays even to browse the web comfortably. At the very least you need 4 or even 6GB or RAM.

| improve this answer | |
  • Before replacing the desktop environment, I'd first try disabling all effects/animations (System Settings > Effects), this alone will make Cinnamon faster and the user experience snappier. I also use Cinnamon on my desktop and it uses only 50-60 MB RAM! – david Aug 26 at 23:09

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.