Issues with srhinking swap

My box has 2x500GB SSDs in a ZFS mirror. The partition table for each drive looks like the following:

1 freebsd-boot (512K)
2 freebsd-swap (18G)
3 freebsd-zfs (448G)

My system has 16G of RAM. I was trying to allot 18G for SWAP. Now, I actually have 36G because I didn't realize that the installer would create a partition on each drive with that amount. I thought that was the total amount.

Anyway, I attempted to delete the swap and then expand the zfs partition, but it seems like I can't expand it to cover the 18G held by the swap. If I want to reallocate the swap, then will I need to reinstall FreeBSD?
 
Why so much swap? You really don't need anything more than 4 maybe 8 GB. If you already have a lot of swap use you need to increase the amount of memory in the machine, not increase swap.
 
I've heard lots of computer guys make statements like amount of swap should equal amount of ram. I've always challenged that. In my opinion size of swap = temp ram deficit.
 
Why so much swap? You really don't need anything more than 4 maybe 8 GB. If you already have a lot of swap use you need to increase the amount of memory in the machine, not increase swap.

Long story short, I picked up FreeBSD again after 9 years of using OS X. I was used to the 2x rule, but then I saw recommendations for temp+2G. So, I tried to do that, but I didn't realize that it would create 2 swap of 18G, 1 on each of my drives. My real question here is whether there's a way for me to shrink the swap partitions and expand the zfs mirror.
 
My real question here is whether there's a way for me to shrink the swap partitions and expand the zfs mirror.
As it's a mirror it should be possible. Remove the swap and zfs partitions (this puts the mirror in "degraded" state) of one of the disks. Create new partitions and re-add the ZFS partition. Then let the resilvering complete to restore the data. Then do the same with the other disk. When both disks have been done ZFS should automatically pick up the increased size.
 
Interesting question.
Can gpart be used to either modify the swap space, or delete and recreate a smaller swap space without hosing the system?
 
Can gpart be used to either modify the swap space, or delete and recreate a smaller swap space without hosing the system?
Sure, just turn off swap (swapoff(8)), destroy the old swap partition and create a new, smaller, one. There's no real need to touch anything else. Although creating a smaller swap will leave a "gap" between it and the ZFS partition but this isn't a problem.
 
While I don't dispute that the rule of thumb for how much swap should be allocated on a system has changed in the last 20 years, I would like to ask: is it worth the trouble to attempt to increase the available disk to ZFS by about 2%?

If you really want to change it, I *think* these are the steps:

0) make a backup of your system that you know you can use to restore
1) turn off swap
2) use gpart to remove the current swap partitions on both disks
3) create new swap slice (probably on both disks)
4) turn swap back on
5) make sure it all works.
6) make sure the mirror is NOT degraded
7) break the mirror
8) destroy one of the ZFS partitions
9) make the slice for the former ZFS partition bigger
10) create a new ZFS partition from the freed space
11) add the new ZFS partition to the mirror
12) wait (probably several days) for the mirror to resilver
13) repeat from step 6 to step 12 for the other disk

Did I miss a step?

I'm sure I got some terminology wrong.

Do not hold me responsible if the above does not work for you. Free advice is only worth what you paid for it.

NOTE: steps 2, 3, 7, 8, 12, 13, and possibly 11 can completely ruin your day if they aren't done right.
 
Back
Top