Swap partition too small :(

Hi all, I just installed Zorin OS Core and I love it so far. However, the swap partition worries me. For my 16GB of RAM, it only created a 1GB Swap partition (default, I didn't change anything).

The problem is, since I chose to encrypt the drive, it's not possible to change resize the partitions, so I'm stuck with 1GB Swap.

This might prove to be an issue in the future, however, I'd wager it's especially an issue on lower-ram devices since that 4GB RAM will quickly be filled up, and 1 GB Swap might not be enough.

I found this thread here talking about the same thing 2 years ago, so thought I'd bump it and create a new one: LVM, LUKS and SWAP - swap volume size too small

By default, Zorin OS creates a Swap File (usually 2gigs) not a Swap Partition.

So I am a bit confused by the description provided.

3 Likes

Willing to bet that's swapfile --

In terminal -

sudo swapoff -a
sudo rm /swapfile
sudo touch /swapfile
sudo chmod 600 /swapfile
sudo fallocate -l XG /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

The XG will be your desired size in GB, so 4G = 4GB, or desired.

Might also want to check your swappiness, in terminal: sysctl vm.swappiness - if it's anything higher than 60, you may want to lower it. Higher numbers for swappiness = more aggressively the swap is used. To change you would need to modify /etc/sysctl.conf at the bottom - add vm.swappiness=XX for XX, 0-100 | 60 is the recommended value. I usually run 50 but it's personal preference for your system and use.

2 Likes

I run swappiness at 200 (the maximum), because I've got 3 swap drives with the same priority, so any swapping will be done round-robin fashion across three drive interfaces and three drives... that's about as fast with spinning-rust drives as a single SSD (without having to worry about write-wear on the drive).

swapon --show
NAME      TYPE      SIZE USED PRIO
/dev/sda2 partition   2G   0B    1
/dev/sdb2 partition   2G   0B    1
/dev/sdc2 partition   2G   0B    1

Some relevant swap commands:

Turn off all swap:
sudo swapoff -a

Zero a swap partition:
sudo dd if=/dev/zero of=/dev/disk/by-partuuid/$swap bs=512 status=progress
You'll have to find the partition UUID of the swap partition you want to zero, and put it in where '$swap' is above. I use 'by-partuuid' because the drive letter (sda, sdb, sdc, sdd, etc.) can change, but the UUID should never change.

Make a swap partition:
sudo mkswap /dev/disk/by-partuuid/$swap -U $swapUUID
You'll have to find the partition UUID and the drive UUID and put them in above where '$swap' and $swapUUID' is. Note that this means you can make up your own $swapUUID, if you want. The script I use to zero all free drive space (to make compressed backups smaller) uses the pre-existing UUIDs of the swap partitions so I don't have to make any changes to the fstab file to get the now-zero'd swap partitions to auto-mount at boot.

Turn on all swap:
sudo swapon -a

2 Likes

Windows is a system designed to use swap constantly, but Zorin OS is not. Relying on swap does not make performance practical.

In my experience I can run Zorin 16 Core with 4GB RAM, but it would be better to install Lite instead.

1 Like

Actually, 2G is too small, too, in my opinion. I had to increase it the way @PlumpKibbles described it. I think the installer should provide an option to set the swap size, or at least provide several defaults, as many arch based distros do in the Calamares installer.

Oh I agree for sure - but it's Ubuntu under the hood; pretty standard in terms of Ubuntu ways, heh. I am glad it's pretty easy now though with the swapfile instead of the partition :wink: I do have a partition on another device, but it's a permanent thing; only 1GB, tiny eMMC storage..

Gday @lakimens , Welcome to the community!

Could you please tell us how you created your bootable device,
What program?
Device (usb,SD card,dvd)?

Are you dual booting?

"1Gb after install says a red flag"

Could you also tell us about your pc
Laptop/Desktop.
Make/Brand/or Motherboard:?
RAM: 16
cpu:?
Drive & size/SSD?HDD:?
Graphics:?

You only need a swap area for HDD's not SSD's. In the unofficial manual for Zorin 15 I wrote how to manually partition the drive at point of install - you choose the 'something else' method.

When partitioning manually I usually just have a primary partition marked for '/' root filesystem of 80 Gb, formatted to Ext4 and flagged as bootable. I then create a logical/extended partition for the remainder of the drive. Before GNU/Linux OS's used swap files they would place the swap area at the end of the drive - so this is what I do when partitioning manually. I create the swap area at the end of the extended/logical partition and make it double the amount of physical RAM on board, so in my case, 32 Gb as I have 16 Gb of RAM. Everything in front of that I format as Ext4 and mark it '/home'. (I normally run 1 Tb Western Digital Black HDDs.)

I never bother with Encryption as experience has shown me that it is oh so easy to lose your data. I always took note of OpenSuse 9.3 Professional's advice that I bought during installation - when you selected encryption option, it warned that their is a chance of data loss - that was enough to convince me that Encryption is a bad idea. It also happened at work. My line manager asked me to make her Business Manager's hard drive secure for confidential data. This was Windows XP, created the Encrypted partition for data, 3 days later the machine fell over, as did all the data. Fortunately, the Business Manager had the nouse to make a backup of her data so only one day's data was lost.

1 Like

As you have 16GB of physical RAM, this shouldn't be much of a worry for you, unless you plan on having hundreds of tabs open in Firefox, are running a video, while editing a video, while playing a game and conference calling on zoom all simultaneously.

It all depends on how you use your computer. Gnome uses 2 to 3GB of RAM, other applications using far less. Do you close applications or keep them open in the background, just in case?

I have 32GB of RAM. With VSCode running, KDE desktop (only a little less memory intensive), Zoom call, Discord Call, Slack and Firefox running.... it was less than 16GB of RAM used while compiling some rather large applications. My swapfile is 2GB, and is never used, even with a very low swappiness threshold.

Your RAM is adequate, depending on use.

I've just automatically followed the double physical RAM advice after extensive research on the matter a long time ago. It has taken me many years to get to a place with a 16 Gb of RAM machine. And in any case I have plenty of space on a 1 Tb drive.

1 Like

16 GB ram is already enough for doing a lot of things on windows, so keeping in mind linux uses far less ram, I dont see how would it be neccessary to have a swap partition

my laptop has 12 GB ram (10.7 GB detected by zorin) and with that I have been able to use a virtual machine of 6 GB, have some tabs open on firefox, do some homework in libreoffice at the same time and there was still some unused ram

If you do some kind of ram-intensive work that requires more than that (maybe a very detailed 3D animation?) then that makes more sense. But for normal daily usage or gaming, you dont really need more

Any reason for that ?

If swap area is accessed many times it means the life of the SSD may be shortened. HDD probably only necessary if low RAM, but I always err on the side of caution!

So what you suggest for SSD ? I have 16 GB RAM

You don't need swap area for SSD. If it puts a swap file in (the installer) it should make itself a suitable size. I cannot check this any more as the SSD went into my eldest's Desktop as their hotswap HDD sounded like it was failing to put Windows 11 on it.

Good read here:

4 Likes

I clicked "Like" on two of @swarfendor437 's posts for good reason.
Swap is useful in the right circumstances: It can prevent an out of memory crash under an intense workload.
But it is not Free RAM.

When the system needs to fall back to swap (Partition or file) there will be a delay in that action. It won't prevent sluggishness, nor will it clear out the unnecessary caching of used data in RAM.

I do not use Swap (I am on SSD)- and when my RAM fills up, even higher than 90%, on Zorin OS, the system clears as necessary, keeping the performance smooth and uninterrupted.
If I enable swap, however, then I get a lot of pauses and delays as the system switches to accessing swap. It is not a smooth experience.

On rare occasions, I may run the following to clear out RAM while working.

sudo sync

sudo sysctl -w vm.drop_caches=3

sudo sync

Warning: It is necessary to sync both before and after clearing RAM!

3 Likes

If you have a SSD as your primary drive, and you need additional swap space due to having low memory, I'd suggest:

  1. get more memory (if possible)
  2. buy a spinning-rust USB drive and create a partition on it, then use that partition as a second swap space, with the same priority as the first swap space.

Nah, it is not my primary mission :slight_smile:

I just want to have in case if needed (when I am playing steam, multittasking , watching YT etc) but that case is really rare

I have 16GB RAM in my Asus laptop - zero swap, but also using NVMe storage. I'm usually sitting around 1 - 2.5GB RAM use on idle; just a tad more with Firefox open. I've not ran into any issues with no swap - even did some 'intense' video editing with Kdenlive lol but, didn't have an effect on RAM - just about 5GB used, and still ~8GB free to use.

To each their own!