SnoppyFloppy
Explorer
- Joined
- Jun 17, 2021
- Messages
- 77
Hi
I have a striped pool of mirrored vdevs that I extended some time ago without considering the distribution of data on the disks and so I want to re-balance the pool to improve performance and distribute disk-wear better.
I'm only somewhat familiar with zfs and though I do have off-side backup of the pool, I would much prefer to not have to replicate everything back in case of a screw-up.
Therefore I pieced together this detailed guide for myself, from info on stachexchange, reddit and here, for that I would very much appreciate if any of you veterans could help me vet. And when the guide are all good, maybe it can help someone else.
NB. I know there are other ways around this - like local copy/paste and even bash scripts that do this but I see this as a zfs learning opportunity
Thanks in advance.
1. Get to the TrueNAS shell either locally or over ssh
2. Get a root shell and start a tmux session
3. Get an overview of your existing pool (oldpool) and copy the output to a text file somewhere
4. Scrub the old pool
5. Stop all services using the old pool, (e.g. shares, k8s, VMs, Etc.)
6. If applicable: move the 'system dataset' to another pool
7. Make a temporary recursive snapshot of the entire pool including all local snapshots
8. Detach one disk from each mirror in the old pool
9. Create a new pool with single-disk vdevs using the detached disks from the old pool
11. Replicate everything from oldpool to newpool
11. Scrub the new pool
11. Destroy the old pool
12. Attach a disk from the now destroyed oldpool to each single-disk vdev in newpool
13. Rename the pool back to oldpool
14. Move back system dataset and restart services
I have a striped pool of mirrored vdevs that I extended some time ago without considering the distribution of data on the disks and so I want to re-balance the pool to improve performance and distribute disk-wear better.
I'm only somewhat familiar with zfs and though I do have off-side backup of the pool, I would much prefer to not have to replicate everything back in case of a screw-up.
Therefore I pieced together this detailed guide for myself, from info on stachexchange, reddit and here, for that I would very much appreciate if any of you veterans could help me vet. And when the guide are all good, maybe it can help someone else.
NB. I know there are other ways around this - like local copy/paste and even bash scripts that do this but I see this as a zfs learning opportunity
Thanks in advance.
1. Get to the TrueNAS shell either locally or over ssh
2. Get a root shell and start a tmux session
Code:
$ sudo -i $ tmux
3. Get an overview of your existing pool (oldpool) and copy the output to a text file somewhere
Code:
$ zpool list -v oldpool | column -t NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT oldpool 30T 20.2T 9.8T - - 0% 67% 1.00x ONLINE - mirror-0 10.9T 9.04T 1.86T - - 0% 82.9% - ONLINE diskID1 - - - - - - - - ONLINE diskID2 - - - - - - - - ONLINE mirror-1 10.9T 9.03T 1.88T - - 0% 82.8% - ONLINE diskID3 - - - - - - - - ONLINE diskID4 - - - - - - - - ONLINE mirror-2 10.9T 2.1T 8.8T - - 0% 19.3% - ONLINE diskIDn-1 - - - - - - - - ONLINE diskIDn - - - - - - - - ONLINE
4. Scrub the old pool
Code:
$ zfs scrub oldpool
5. Stop all services using the old pool, (e.g. shares, k8s, VMs, Etc.)
6. If applicable: move the 'system dataset' to another pool
7. Make a temporary recursive snapshot of the entire pool including all local snapshots
Code:
$ zfs snap -r oldpool@migration
8. Detach one disk from each mirror in the old pool
Code:
$ zpool detach oldpool DiskID1 $ zpool detach oldpool DiskID3 $ zpool detach oldpool DiskIDn-1
9. Create a new pool with single-disk vdevs using the detached disks from the old pool
Code:
$ zpool create \ -o ashift=12 \ -o atime=off \ -o compression=lz4 \ -o xattr=sa \ -o encryption=on \ -o keylocation=file:///path/to/encryption-key.json \ -o keyformat=hex \ newpool \ mirror DiskID1 \ mirror DiskID3 \ mirror DiskIDn-1
11. Replicate everything from oldpool to newpool
Code:
$ zfs send -R oldpool@migration | zfs recv -Fuv newpool
11. Scrub the new pool
Code:
$ zfs scrub newpool
11. Destroy the old pool
Code:
$ zfs destroy oldpool
12. Attach a disk from the now destroyed oldpool to each single-disk vdev in newpool
Code:
$ zpool attach newpool DiskID1 DiskID2 $ zpool attach newpool DiskID3 DiskID4 $ zpool attach newpool DiskIDn-1 DiskIDn
13. Rename the pool back to oldpool
Code:
$ zpool export newpool $ zpool import newpool oldpool
14. Move back system dataset and restart services
Last edited: