Upgrading Disks Question

My primary array currently has 3 18 TB SATA drives in Z1 and as now have 5 18 TB SAS drives that I want to use to replace them with, also in Z1.

If at all possible I would prefer to keep the Pool the same with the same path and name.

I know if it was the same number of drives I could do a slow but sure 1 by 1 replace and resilver but I don’t see how that would work when adding 2 extra drives.

It know it’s possible to add a new ZVOL to the pool with the new drives in a Z1 arrangement for expansion; but is it possible to force the data to move to it?

This is RAIDZ expansion, and was only recently enabled. See TrueNAS Tutorial: Expanding Your ZFS RAIDz VDEV with a Single Drive [YouTube Release] - Youtube Releases - Lawrence Systems Forums

2 Likes

I think you’re thinking of a vdev, and you’d need at least three disks to do that.

You can simply add the two disks, one at a time, to your vdev, following the guide Samuel linked, and then replace the other three, leaving you with a five-wide RAIDZ1 vdev. However, RAIDZ expansion keeps the existing data:parity ratio for any existing data, and often results in available space being reported incorrectly. You can address this, at least to a degree, using zfs rewrite, as described in more detail here:

1 Like

Thanks, this was exactly what I needed.

Yes, I did mean VDEV,

Thanks for confirming what @Samuel_Tai said. I don’t know why that my own searching didn’t turn up anything about RAIDZ expansion.

This does not re-stripe data, at least according to the manual page. This “rewrite” applies to blocks, not files, so it can’t really re-stripe the file to any newly expanded RAID-Zx width.

While that command is useful, the old full copy script DOES re-stripe the data blocks in a file. Further, it appears that “rewrite” does not change block size, but the old fully copy script should do so.

1 Like

Thanks for the clarification. So would it be safe to say that zfs rewrite would be beneficial to, e.g., rebalance data when you add a new vdev to a pool, but not to address RAIDZ expansion?

Wow, first I heard of this and it doesn’t seem to exist on my CORE installation, but is available on my FreeBSD 15.0 server so this must be relatively new.

Does that mean that you can now rebalance your pool simply by doing zfs rewrite -r /path/to/dataset?

Seems only to operate at the file level, instead of the dataset or pool level. Probably need to use find /mnt/<pool name> -execdir zfs rewrite '{}' \; to apply it to the pool.

I would think that’s what the -r flag does, no?

1 Like

This is the script you’re referring to?

Yes.

And to re-do compression, checksum, copies and de-dup, within existing ZFS blocks for files.

Probably. I’ve not used such, but it seems to be the proper tool.


We probably need a standard blurb about how RAID-Zx writes data, including the variable width stripes. And that you can have large files, like a 1GB file that if written slowly, (like a log file), would end up using small stripes. Even single data column stripes. Thus, more metadata and parity that if it was copied as a single operation.

Looking at the ZFS man page for zfs-rewrite, it does rewrite files but at the block level.

So something like this:

zfs-rewrite -r /mnt/[Pool]/

Should recursively copy and rewrite the blocks of every file in the pool.

or zfs-rewrite -r -v /mnt/[Pool]/

to track the output.

It sounds like the type of command that will require tmux to use properly on large pools.

Nah, you can just use the & operator to get it to run in the background detached from the terminal though tmux is more robust.

That does not always work.

Generally if not using TMux or Screen, then nohup should be used as well. For example:

nohup COMMAND >/dev/null 2>&1 &

Sorry to toss a monkey wrench here, but if possible i would suggest creating a separate pool and duplicate of the datasets and then doing some sore of ZFS renaming operations might be safer if possible.

Perhaps you should look into that.

It’s too late for this operation but I will have other pools to move.
I didn’t think it was possible to rename pools safely.
What would your method be here?

It’s possible, but not through the GUI:

  • Export the pool through the GUI
  • At the shell, zpool import oldname newname (where oldname and new name refer to the old and new pool names, respectively)
  • zpool export newname
  • Import the pool using the GUI
1 Like