I haven't created a swap partition, should I add one?

First up, I’m a filthy dual booter, please don’t judge me.
Mainly because of gaming and my work, most clients currently adopt a lot of the m$oft stack
I’ve been mucking about with linux for the last 18 months and I’ve been enjoying Manjaro on this machine for the last 6 months.

I have an NVME drive which is partitioned :

  1. NTFS recovery partition for W
  2. EFI /boot/efi
  3. NTFS for Windoesn’t
  4. EXT4 for manjaro /

The Manjaro /home is mounted on another spinning disc

What I’ve noticed is that I’ve allocated a lot of space for the 4. root partition and its not really being used at all. there’s about 15 GB used out of the 244G available… I am thinking I should just boot to live, run Gparted, shrink the / partition and add a swap of 30GB at the end, then add an entry to FSTAB,

Is that all I need to do?

I have two x 8GB sticks of DDR4, so it’s reasonably beefy. I remember hearing/listening about still needing /recommending to still have a swap partition just in case.
Is this general consensus? OR should I just leave it be?

my beast:
$ inxi -a
CPU: 8-Core AMD Ryzen 7 2700X (-MT MCP-) speed/min/max: 2027/2200/3700 MHz Kernel: 4.19.69-1-MANJARO x86_64 Up: 4d 21h 02m
Mem: 9194.6/16030.6 MiB (57.4%) Storage: 3.87 TiB (3.0% used) Procs: 368 Shell: bash 5.0.9 inxi: 3.0.36

I’ve not got any real big use cases, this is my home office PC. On Manjaro I’m likely to be:

  • running some VM’s - other distros
  • tinkering with python, HTML CSS;
  • minecraft, steam games;
  • testing/exploring FOSS software; and
  • the odd video rendering job to help my partner in her work

I’ve not had any problems, just looking for advice or general consensus on the use of Swap partitions.
I’m kinda also looking to tinker :slight_smile:
Cheers
Scooter

3 Likes

First I’m no expert but on systems with 16Gb Ram or more If SSD/HDD space is an issue (which most of the time it’s not these days) I’m not that fused about swap. Some would say keep swap to a minimum on an SSD due to the potential to exceed to read/write limits but on modern SSD’s with read/write life of each bit being between 10,000 and 100,000 over the life of the Drive this is no longer a major concern unless you had very small amount of RAM and were constantly writing to swap.

As for creating a swap partition after you have partitioned the drive, I think you can do this with Gparted or another partition tool from a live disc, resize the primary partition creating an unused section on the drive of the required size, then format this as Swap, remembering to activate it after you create it by switching Swap ON.
After you reboot back into the PC you should now have an active Swap of the size you created. The other safer option than re-partitioning the OS Drive which can risk losing data, if you have an SD card slot you could re-purpose a reasonable quality SD Card as a swap partition it wont be as fast as the on board SSD but if you have a spinning drive it will be as good if not better for a swap partition. The downside is you lose access to your SD card bay.

2 Likes

I think it depends on your usage. I have 16GB of RAM in my daily driver. I don’t do any video production and rarely play games. I keep an eye on memory usage with glances, and I never get close to using the whole 16 GB, even using GNOME. So, for me there’s been no need for a swap on that box. If you do more audio and video production or run other memory-intensive applications or VMs, it might be worth it.

1 Like

Swap is more than just whether you run out of RAM or not. Swap needed for people who want to use hibernation on their system.

If you have a lot or RAM it is true that there is not much of a “need” but there is no real point to not have Swap. It basically boils down to “do you need it?” not really but there are benefits to having it so you might as well.

Now here is one of the best things about Linux . . . if you didn’t make a Swap partition, you’re fine you can also make a Swap File instead because those dont take up permanent space as they only take up space that they are using. If you aren’t using Swap at a given time then the file is pretty much super tiny.

In fact, I am pretty sure that Ubuntu switched to using a Swap File by default instead of partitions with the latest releases. I would recommend Swap Files in general but in this case certainly because it doesnt require you to repartition anything.

This process is a little bit involved and I dont know of a tutorial right now that I would recommend because I havent looked for tutorial for this in a while. When I get more time I will either find an existing tutorial for you or just make my own. I don’t know when that will be so feel free to look for a tutorial for creating a Swap File.

4 Likes

Thanks everyone.
Really appreciate the input and suggestions.
The hibernation idea is one I think I need to look into.
I’ve found a tutorial that seems straightforward Everything Swap - Manjaro wiki

I’ll give this swap file a go instead of the re-partitioning.
Cheers!

2 Likes

I’d say with 16Gb of ram, swap isn’t really needed. I run with 16gb myself and haven’t got a swap at all. In fact the most ram I have in use, even running with Win7 in a VM, WoW, multiple Firefox tabs open, and Spotify running, is about 12Gb.

Swap is a relic from a time when machines didn’t have enough ram to load everything at once.

On older machines where Linux is being used to get a bit more shelf life then yeah, I can see it being used, but on a decently specced machine, I’d go with no.

2 Likes

Plus one on the swap file thing.

2 Likes

i follow this guide and just make a swapfile instead of a partition, then after i bootup i can turn it on if i need or want via: sudo swapon /swapfile https://linuxize.com/post/create-a-linux-swap-file/

2 Likes

The point about needing a swap to hibernate is good if true. For what it’s worth, I have a 4 GB swap partition on a Pop!_OS 16 GB system with Gnome DE and routinely have applications open and running on 4-5 different workspaces. Every time I’ve checked, my swap usage has been zero.

Digital Ocean is a good resource for many things. How To Add Swap Space on Ubuntu 16.04 | DigitalOcean

3 Likes

This is exactly what I was going to suggest. Follow these instructions and you can make whatever swap file size makes sense for you in a matter of minutes.

Also, I recently ran into a situation where, even though I have 16GB of RAM I forgot I had other VMs running and launched another causing me to exceed my physical and 2GB swap. The machine did eventually recover but I thought I had lost many hours work. I immediately created a 16GB swap partition and got on with my life. The fact that most distros only create 2GB by default can be a problem. Disk space is generally not an issue for most people so I can’t quite figure out why that’s the standard size. :man_shrugging:

4 Likes

Well I think I sent a note of thanks too soon!

Thanks again everyone for all the advice
and @douhunt, the swap space tutorial was so simple to follow.:+1:

I think I might need to up my swap size in order for hibernate to work… but that’s a whole other topic.
Right now I’ve just installed Ubuntu Mate 19 Beta on a VM to check out.

Cheers! :beers:

Just trying to expand the topic with a noob question:

  • In case I have 2 Linux OS-es on one SSD drive: will it be better, in that situation, to have one Swap partition which both of that two OS-es will use instead to have two Swap files on both OS partitions? (double space required)
    Another one:
  • Is it possible to create Swap file on the first partition that even OS from the second partition will use when it’s active? Is that a good idea? (have on mind possible recoveries etc…)

Thank you in advance!

1 Like

Thank you! for your advise! I don’t know any tutorial on this matter, but I found this article on askubuntu:https://askubuntu.com/questions/1075505/how-do-i-increase-swapfile-in-ubuntu-18-04.

In the first case, yes, you can create a dedicated swap partition and share it between systems. Installers will normally use a swap partition automatically if there is an existing one available. For the second point, yes, you could do this but you’d have to mount that partition at boot to access a swap file contained within. I’m not sure why you’d want to do that if you prefer swap files to partitions unless the root partition of the second system is too small to house its own swap file. Hope that makes sense.

1 Like