How to remove legacy swap partitions?

I have a system which has been gradually upgraded up to Electric Eel. A few days ago, a drive in my 6-wide Z1 array has started failing and I replaced it with a spare. During the resilvering process, I noticed that the new drive doesn’t have the 2 GiB swap partition that the others have. Looking further, I found out that in 24.10-BETA.1, the creation and management of swap space was removed. Of course, the old drives still have the default partitions.

I’m now left with an asymmetrical array:
Old drives:

Device       Start         End     Sectors  Size Type
/dev/sda1     2048     4196352     4194305    2G Linux swap
/dev/sda2  4198400 35156654080 35152455681 16.4T Solaris /usr & Apple ZFS

New drive:

Device     Start         End     Sectors  Size Type
/dev/sdc1   2048 35156654079 35156652032 16.4T Solaris /usr & Apple ZFS

I can’t find a way of fixing it using the web UI, and I’m aware that partitions/filesystems should only be handled with a plan. There are two options: Remake the new drive with swap, or remake the 5 old drives with no swap. I prefer the second option since Electric Eel doesn’t seem to use the swap partitions (according to $ free) and I don’t even really need it (2 GiB per drive compared to 192 GiB of memory). The array was only created like that because I didn’t notice the default setting (probably the reason for the devs removing swap management outright).

What I’m thinking is to tell ZFS to forcibly discard and resilver the old drives one at a time. I hope there’s a clean way of doing this, otherwise I could just wipe the partition tables and make it try to remount.

Any advice is appreciated!

How about not doing anything and let it work. The SWAP space provides you two functions as I recall:

  1. If you run out of RAM, the data in RAM can be temporarily placed into the SWAP space so RAM can be used to keep the system operational. This is a great feature however in my opinion, a properly built system should never run out of RAM in the first place.
  2. When you have drives that are of slightly different sizes, the SWAP space supposedly will adjust to ensure the data partition is the same size as the rest of the system. I don’t know if this is true, maybe it is.

What to do: Check your SWAP space usage in the GUI. Are you using any? A few bytes is not of concern. A 100kb or more is something to look at.

So my advice, don’t mess with it. You already have a few 2GB SWAP partitions on your system. I’ve read that if you create a new boot drive and it has over 64GB, that is will offer you the option to place create a 16GB SWAP partition on the boot drive. So things are moving off the old data drives.

Hope this helps some.

EDIT: Crap, I didn’t answer your question on how to remove your SWAP partitions on your original drives…

You have a RAIDZ1 so I would first add a new (replacement) drive to “replace” one of the drives in the system. Remove the original drive from the pool, then wipe the partition tables on the drive. Then use that drive to add into the pool and replace another old drive, rinse and repeat. Look at the TrueNAS user Guide on how to Replace a drive. this is not the same as replacing a drive due to failure.

Also read about Wipe the disk in the manual. That freakin’ manual has a lot of good stuff in it.

3 Likes