Re: Swap, ZFS & ARC

From: Alan Somers <asomers_at_freebsd.org>
Date: Thu, 02 Feb 2023 16:04:02 UTC
On Thu, Feb 2, 2023 at 8:45 AM <jbo@insane.engineer> wrote:
>
>
>
>
>
>
> ------- Original Message -------
> On Thursday, February 2nd, 2023 at 14:41, Eugene Grosbein <eugen@grosbein.net> wrote:
>
>
> >
> >
> > 02.02.2023 21:28, jbo@insane.engineer wrote:
> >
> > > Hello folks,
> > >
> > > Based on a discussion on the forums not so long ago I tried to figure out how swap usage on a ZFS system plays together with ARC. However, I could find very little to no information on this which leads me to believe that there is some "core concept" I might be oblivious to.
> > >
> > > The main question is basically this: Your system starts to swap out data from RAM to your swap partition.
> > > This swap data on disk ultimately resides somewhere in a ZFS pool.
> >
> >
> > I prefer not doing this. That is, all my systems have swap partition outside of ZFS pool.
>
> This isn't really achievable on your average "single disk" desktop systems, right?
> Assuming I'm not missing something (which is why I came here to ask), a "regular" or "default" installation through the FreeBSD installer would setup a swap partition within the zpool, right?

Actually, the installer by default sets up a swap partition beside the
zroot pool.  It doesn't use swap-on-zvol.  Here's what it looks like:

> gpart show
=>        40  1953525088  nvd0  GPT  (932G)
          40      532480     1  efi  (260M)
      532520        1024     2  freebsd-boot  (512K)
      533544         984        - free -  (492K)
      534528    16777216     3  freebsd-swap  (8.0G)
    17311744  1936211968     4  freebsd-zfs  (923G)
  1953523712        1416        - free -  (708K)

=>        40  1953525088  nvd1  GPT  (932G)
          40      532480     1  efi  (260M)
      532520        1024     2  freebsd-boot  (512K)
      533544         984        - free -  (492K)
      534528    16777216     3  freebsd-swap  (8.0G)
    17311744  1936211968     4  freebsd-zfs  (923G)
  1953523712        1416        - free -  (708K)

> zpool status zroot
  pool: zroot
 state: ONLINE
  scan: resilvered 314G in 00:10:19 with 0 errors on Sat Dec 24 22:31:04 2022
config:

    NAME        STATE     READ WRITE CKSUM
    zroot       ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        nvd0p4  ONLINE       0     0     0
        nvd1p4  ONLINE       0     0     0

> swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/gpt/swap0    8388608        0  8388608     0%