Swap space + drive replacements

Status
Not open for further replies.

dzog

Cadet
Joined
Apr 12, 2017
Messages
7
Hey folks!

Currently building my first FreeNAS server.

When I built arrays on other platforms, I would always partition the disks to be slightly smaller than the rated size in order to allow for fluctuations between "same-sized" drives in the future when replacements are needed and the exact original drives may be unavailable or prohibitively expensive for whatever reason.

When looking into whether or not FreeNAS does something like this automatically, or otherwise easily allows for it, I discovered that FreeNAS creates 2GiB swap partitions on all my disks when adding them to a volume:

Code:
root@freenas:/dev # gpart show /dev/da0
=>		 40  15628053088  da0  GPT  (7.3T)
		  40		   88	   - free -  (44K)
		  128	  4194304	1  freebsd-swap  (2.0G)
	  4194432  15623858688	2  freebsd-zfs  (7.3T)
  15628053120			8	   - free -  (4.0K)


It looks like these are active swap used by the OS:

Code:
root@freenas:/dev # swapinfo
Device		  1K-blocks	 Used	Avail Capacity
/dev/ada0p1.eli   2097152		0  2097152	 0%
/dev/ada1p1.eli   2097152		0  2097152	 0%
/dev/da0p1.eli	2097152		0  2097152	 0%
/dev/da1p1.eli	2097152		0  2097152	 0%
/dev/da2p1.eli	2097152		0  2097152	 0%
/dev/da7p1.eli	2097152		0  2097152	 0%
/dev/ada2p1.eli   2097152		0  2097152	 0%
/dev/ada3p1.eli   2097152		0  2097152	 0%
/dev/da3p1.eli	2097152		0  2097152	 0%
/dev/da4p1.eli	2097152		0  2097152	 0%
/dev/da5p1.eli	2097152		0  2097152	 0%
/dev/da6p1.eli	2097152		0  2097152	 0%
Total			25165824		0 25165824	 0%


This led me to some thoughts/observations:

- The 2GiB swap partition does turn my 8,001,563,222,016 byte (~8001.56 GB) disks down to a more comfortable 7,999,415,648,256 bytes (~7999.42 GB) actually used as vdev members

- Other than the swap space, FreeNAS does appear to use the entire disk (e.g. no specific provision for "very slightly smaller replacement disks")

- If I wanted to replace a drive with a slightly smaller variant, it seems I could just cut down on swap spaced used to make it work. I'm curious: is this something that FreeNAS would handle by itself when I went to replace a disk in the GUI, or would I need to manually make things happen in the shell?

- What's up with the swap space? Will FreeNAS really swap RAM into bare partitions on spinny disks instead of to, say, a zfs volume? Doesn't that seem kind of unsafe, or at least more dangerous than being in ECC RAM?

- How do others proactively solve for the "8TB disks can all be different sizes (pretty close to and hopefully at/exceeding 8.0e12 bytes)?" problem when dealing with replacements down the road?
 
Last edited:

gpsguy

Active Member
Joined
Jan 22, 2012
Messages
4,472
Yes, FreeNAS will automatically adjust the swap space, if the replacement drive is slightly smaller than the original one.

I'm curious: is this something that FreeNAS would handle by itself when I went to replace a disk in the GUI

One should use sufficient RAM, such that it's unnecessary to use swap, other than for disk replacements.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Doesn't that seem kind of unsafe, or at least more dangerous than being in ECC RAM?
That's because it is. The only thing that keeps from being a constant disaster is the fact that swap is never really used unless things are already seriously messed up.

FreeNAS 11.1 is going to switch to GEOM mirroring swap in groups of two drives, to improve reliability.

- If I wanted to replace a drive with a slightly smaller variant, it seems I could just cut down on swap spaced used to make it work. I'm curious: is this something that FreeNAS would handle by itself when I went to replace a disk in the GUI, or would I need to manually make things happen in the shell?
Good question. Either it does, or drives are consistent enough for it not to matter.
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Yes, FreeNAS will automatically adjust the swap space, if the replacement drive is slightly smaller than the original one.
No, it doesn't do this automatically, but you can do it manually if needed. But for the last several years, drive capacities have been pretty well standardized, so it shouldn't be necessary.
One should use sufficient RAM, such that it's unnecessary to use swap
I don't think "sufficient RAM" has anything to do with it--I use swap a bit, even with 128 GB of RAM. Not much, most of the time, but it's still used.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Might as well add that GELI is also involved, since swap is encrypted.
 
Status
Not open for further replies.
Top