Is the Swap Partition required?

Hello,

I am installing my TrueNAS SCALE system which is right now only equipped with the boot SSD drive, the HDDs will arrive the next days/weeks. The installer asks if it shall create the SWAP partition on the boot drive. For my understanding, the SWAP should not be located on flash memory, but on the harddrives.

Do I need to configure a swap partition on my boot drive right now or can I simply tell the installer to not create the swap?
Hint: The system is equipped with 256 GB of RAM.

If I create the swap partition right now on the boot drive, could I simply “move” the swap later to another drive?

If I will add my harddrives later. Will TrueNAS SCALE then automatically add a distributed/redundant swap partition over all of the harddrives or will this be an additional step that has to be done manually?

Thanks a lot in advance,

Thomas

Given the recent problems with Dragonfish and swap usage i’d say don’t create swap…
See Very slow WebUI - Login, Apps, etc. SCALE Dragonfish RC - #31 by Jorsher for further information

Why? If swap ever comes to be used, you’d want it to be as fast as possible.
Anyway the boot drive cannot have any other function; it can as well take swap.

2 Likes

Because of the high flash memory wear if the swap content is regularly written onto the SSD.

I personally believe in swap. Without another long post, the basic idea is that ZFS memory resizing seems to lag behind a bit. If I start a VM say and the arc has filled memory, I want to avoid any OOM errors. Or anything else that might consume quite large amounts of memory. For that reason, I LIKE swap, it would be temporary. You can tune how much you want to swap in and out for the most part with a variable. Linux systems often use swap for stuff that doesn’t matter, there is nothing wrong with swap use UNTIL it starts swapping in and out a bunch of course.

I definitely would try and avoid swap on hard drives. But there are obviously differences of opinion on that.

Yes, there are some posts about swap in that other thread. Most are not convincing at all. I think it’s somewhat of a misunderstanding of swap and Linux, there is another cause there. More important than to swap or not swap is the fact that so many are installing the .0 release. IMHO. But it could well be the case for those that have already installed the .0 release and have that issue that disabling swap temporarily until whatever the problem is is fixed might be warranted, not saying it’s isn’t a potential mitigation.

Example of OOM:

1 Like
  1. You should not be using Flash drives under any circumstances because they will fail fast. Use of SSDs is fine if that is in fact what you meant.

  2. I would agree that you should disable the creation of swap space on all your HDDs - if you need swap then SSD would be better in this day and age.

  3. The boot drive can have other functions i.e. you can have one or more non-boot pools on it, and I have done this and upgraded without issue several times - however this is NOT a configuration supported by ixSystems so if you are going to do this you need to do so having made an informed decision knowing the risks, and (IMO) you should NOT do this if you are an Enterprise Customer or will need support from them.

That said, I have a memory constrained system (10GB), and have defined a similar sized (16GB) swap on my SSD boot drive, but I am yet to see the swap space usage go above 512MB. It is possible that part of the memory used by my apps gets swapped out - I don’t know how to determine what has been swapped, but I suspect that ARC is freed when memory is needed rather than LINUX swapping anything out to SSD.

The problem here is that SSDs are (or perhaps “contain” would be a better word) flash memory, making this statement more than a little confusing–and it’s likely this is the confusion OP is running into. USB memory sticks, often called flash drives, are a bad choice for anything that needs frequent use. They’re fine for an installer, not for a TrueNAS boot device. Decent quality SSDs, also flash devices though not normally falled “flash drives,” are fine for this application. They do have a finite write lifespan, but a swap partition on an otherwise properly-resourced system shouldn’t be a problem at all.

It can, but it really isn’t a good idea unless you really need it. SSDs, especially smaller ones, are cheap. Places to put them are usually cheap. Don’t needlessly complicate your administration of the system just to save a few bucks.

1 Like

That’s exactly the point, for me also an SSD is a “flash drive”, because the drives contain flash memory cells. But if I got it right, here in the forum “flash drive” only means USB memory sticks, SD cards, etc. but not SSDs. Is this definition correct?

This means that placing the swap partition on an SSD will be fine, correct?

That’s how we tend to use the term. Even more broadly, I don’t think “flash drive” normally refers to SSDs, even though they are made with flash memory.

It should be fine, especially with how overprovisioned the boot device is going to be.

If your NAS hardware is an enterprise server with many SATA ports and / or M.2 slots, then I would fully agree with this statement.

But many of us are building NAS’ on a budget, and are using commercial appliances rather than a DIY appliance or an enterprise server, and SATA slots are at a premium and we want to use them for primary storage. When you are budget constrained, compromises are often necessary. Unlike a business environment where extended downtime would be a problem, in a home environment if your NAS is down for a day or two because you don’t have redundant boot drives, this may be something that you can live with in order to save quite a lot of money on the server hardware that you can then spend on disks.

What I am saying is that everyone has their own particular circumstances and compromises like this are OK just so long as you understand and accept the risks and consequences of making them.

P.S. There is a little (and I really mean a little) more administrative complication to setup a shared boot drive, however my experience is that once setup the administration of my system is really no more complicated than any other similar system without these compromises.