I use ZFS on all hard drives. The current setup, is that I have 2 hard drives in no raid or redundancy, just in two VDEVs in a ZFS Pool because I have more data than the capacity of one hard drive. This is then backed up irregularly to another system, where the same situation is set up, 2 VDEVs. That means, I have no redundancy on either of these systems.
Now with the addition of the new hard drives, I’m able to make the primary system at least redundant (and expand the capacity), while expanding the backup capacity too (however, still no redundancy there). As the newly purchased hard drives will go to the backup system as well as I’m changing VDEVs, I need to shuffle data around. I have a ZFS pool, called storage on the primary system.
Please note, that I’m showing the path of all hard drives below, but I actually use WWNs to make sure, that even if the path changes, I use the same hard drives everywhere.
The plan
is the following:
- Create a new pool, named
storage_tmpwith the new hard drives in mirror mode (they are large enough to accommodate all data and I’ll gain redundancy immediately) using:sdhsdi
- Create the snapshot
transferon the old poolstorage - Send the snapshot
storage@transferto the poolstorage_tmp - Once prepared for the change, create a new snapshot
transfer_finalonstoragepool - Stop all processes that would access data on
storage - Send the incremental snapshot
storage@transfer_finaltostorage_tmp - Double check if all data is copied to
storage_tmp - Destroy the
storagepool - Create the
storagepool with RaidZ2, usingsdesddsdasdf
- Move back the snapshot
storage_tmp@transfer_finalto the newly created poolstorage - Restart applications
- export the temporary pool
storage_tmp
Preparation
The state of the storage pool, before starting.
| |
Create Temporary Pool
Create the pool storage_tmp
| |
Confirm that the new pool is created correctly as mirror
| |
Transfer data from storage to storage_tmp
Create the transfer snapshot
| |
Start the copy of the storage@stransfer snapshot to storage_tmp
| |
I’m using the flags:
zfs send -Rto recursively send all snapshots before this snapshot as well as sending all snapshots recursivelyzfs recv -Fto force a rollback on the destination (this is unnecessary in this case. However, if there would be an older snapshot received on the destination and the data woul’ve been changed, this would roll back the dataset)zfs recv -vto show the progress of the transferzfs recv -uto not mount the filesystem after receiving it
Once I’m ready to the last data transfer, stop all applications that might use the data. Then create a new snapshot and send an incremental backup with ZFS send.
| |
Send the incremental
| |
The flag -I (capital i) defines the 2 snapshots, in between all snapshots will be replicated. In the above command, ZFS will send all snapshots that were created since the creation of the @transfer snapshot until (and including) @transfer_last.
Make sure, that the received data is correct
| |
Prepare the new storage pool
Double check that you have all data, then destroy the old pool. This is irreversible and will delete ALL data on the old pool! Always triple check!
| |
Create the new pool
| |
I use the flag
-f, because not all my disks are the same size
Send the data back from storage_tmp to storage
Send back all the data to the storage pool
| |
Once the transfer is complete, double-check if the is copied back. The filesystems should be mounted, but if not, mount them.
| |
Export storage_tmp to make sure, that it’s not used anymore.
| |
Restart applications and check if they are up and running.
Summary
With this method, I was able to move data temporarily to a different pool, change my primary pool and move data back.
ZFS is awesome.