ZFS The best strategy for adding swap

Hi! According to Klara's recommendations I would like to add a 64G swap. Swap will be added to both disks where zfs partitions are mirrored now:
Code:
root@test:~ # gpart show
=>        40  1875384928  diskid/DISK-11111111111111  GPT  (894G)
          40      532480                           1  efi  (260M)
      532520  1874852448                           2  freebsd-zfs  (894G)

=>        40  1875384928  diskid/DISK-22222222222222  GPT  (894G)
          40      532480                           1  efi  (260M)
      532520  1874852448                           2  freebsd-zfs  (894G)

Then the swap partitions will also be mirrored.

The problem is that such an action will require temporarily disconnecting one of the disks from the pool, then creating new partitions, including swap, and mirror (or copy) ZFS data to smaller ZFS partition (it will decrease due to swap being added to both disks).

But I won't be able to make a mirror from the first and second ZFS partitions, since the second one will have a smaller size.

What options are there? Only zfs send/receive?
 
You created a ZFS mirror with the 894G partitions, yes? Not "create a GEOM mirror and then a zpool on top of the GEOM mirror"?
This is speculation on my part:
I think you could detach one of the drives, repartition to give you swap partition, then attach the new smaller partition in the mirror. Yes, the overall size of the mirror will reflect the smaller size, but I think it should resilver, as long as the 894G partition is not almost full. Once it does that, detach the other partition from the mirror, repartion the same, reattach and let it resilver.
If the system won't let you attach the smaller partition, then yes I think zfs send/receive is the only option
 
  • Thanks
Reactions: dnb
You created a ZFS mirror with the 894G partitions, yes? Not "create a GEOM mirror and then a zpool on top of the GEOM mirror"?
...
Right, not GEOM mirror, just ZFS mirror with 894G partitions.
then attach the new smaller partition in the mirror.
You understood everything absolutely correctly. But can we attach a smaller partition to a larger one? I was only able to attach a larger partition, and even an entire larger disk. But no less. In last case, I received a message that there was not enough space on the partition. Should ZFS connect a smaller batch?
 
Should ZFS connect a smaller batch?
I think it used to be able to which caused people to have problems. If the system tells you "you can't do that" then perhaps they've fixed that.
If you can't then detach repartition, zfs send is one way.

Or if you have more device connectors, why not simply add more devices?
 
  • Thanks
Reactions: dnb
Dear dnb,
you could create to empty files using dd and fill them with a zfs mirror, just as in your setup but very small scale. Then it should be possible to try what you want to achieve on that tiny mirror. If that fails it will likely fail in the larger scale, too. If it works it also might work in the larger scale.
 
  • Thanks
Reactions: dnb
To not depend on the partitions you could also use Zvol for the swap.

In solaris systems the swap is directly a Zvol that can be expanded directly by changing the volsize value or by creating a new volume and adding it. But I have never used it in FreeBSD, I don't know if it is a completely valid method.
 
  • Thanks
Reactions: dnb
I think it used to be able to which caused people to have problems. If the system tells you "you can't do that" then perhaps they've fixed that.
If you can't then detach repartition, zfs send is one way.

Or if you have more device connectors, why not simply add more devices?
Here is an example of an attempt to attach a smaller partition.
 

Attachments

  • test.png
    test.png
    64.1 KB · Views: 27
  • Like
Reactions: mer
Ok, so that corner case was closed off. It's a good thing. So I think zfs send/receive or additional devices are about all you can do.
 
  • Thanks
Reactions: dnb
Back
Top