ZFS/FreeNas migration of data to a new zpool
This is a copy of the information provided in the link below. The data from an existing zpool (tank) is moved to a new zpool (tank), which is then renamed to the orginal name (tank).
Starting with existing zpool 'tank' and a new empty zpool 'dozer', the steps are:
- Make snapshot of tank and send it to dozer (this may take a long while)
- When the cut-over is about to occur
- Ensure the disk isn't in use (shutdown iSCSI, NFS, syslog, etc)
- Make another snapshot of 'tank' and incrementally send it to 'dozer' (this should take a short time)
- Set 'tank' as readonly
- Export the two zpools
- Rename and import the original zpool as'digger'
- Rename an import the new zpool as 'tank'
# zfs snapshot -r tank@01 # zfs send -R tank@01 | zfs receive -Fdvu dozer # zfs snapshot -r tank@02 # zfs send -R -i tank@01 tank@02 | zfs receive -dvu dozer # zfs set readonly=on tank # zpool export tank # zpool export dozer # zpool import tank digger # zpool import dozer tank
Note: unmounting a ZFS filesystem can assist in freeing space (if some process is holding onto a handle with those resources).
Links
- http://portrix-systems.de/blog/brost/zfs-migration-using-incremental-sendreceive/
- http://everycity.co.uk/alasdair/2010/07/using-mbuffer-to-speed-up-slow-zfs-send-zfs-receive/
Appendices
Destroy snapshots
Recursively destroy (delete) snapshots:
# zfs destroy -r tank@01
List Snapshots
# zfs list -t snapshot
Mount/Unmount
# zfs mount tank # zfs umount tank
Set mount point
# zfs set mountpoint=/mnt/tank tank
Quota exceeded
If the destination was present then destroy it before performing the first sync.
# zfs send -R tank/ds-mirror@01 | zfs receive -Fdvu dozerreceiving full stream of tank/ds-mirror@01 into dozer/ds-mirror@01 cannot receive new filesystem stream: destination dozer/ds-mirror space quota exceeded warning: cannot send 'tank/ds-mirror@01': Broken pipe