Solaris‎ > ‎

ZFS

ZFS is one of the best storage virtualisation products I have ever used. It is also bundled with Solaris at no extra cost.

How to replicating an entire ZFS pool to a new pool, retaining all datasets and their origins
:

We have two pools. “source_pool” (4 GB) has a standard image with a snapshot. Eight clones have been made from this snapshot. ZFS shows that “source_pool” takes up 1 GB of physical disk space:

# zfs list
NAME USED AVAIL REFER MOUNTPOINT
source_pool 1.00G 2.91G 31K /source_pool
source_pool/copy1 0 2.91G 1.00G /source_pool/copy1
source_pool/copy2 0 2.91G 1.00G /source_pool/copy2
source_pool/copy3 0 2.91G 1.00G /source_pool/copy3
source_pool/copy4 0 2.91G 1.00G /source_pool/copy4
source_pool/copy5 0 2.91G 1.00G /source_pool/copy5
source_pool/copy6 0 2.91G 1.00G /source_pool/copy6
source_pool/copy7 0 2.91G 1.00G /source_pool/copy7
source_pool/copy8 0 2.91G 1.00G /source_pool/copy8
source_pool/image 1.00G 2.91G 1.00G /source_pool/image
source_pool/image@final 0 - 1.00G -
target_pool 72K 1.95G 21K /target_pool


Let’s say I want to replicate all of this data to “target_pool” (2 GB). Because we used “zfs snapshot” and “zfs clone”, Solaris sees 9 GB of data in “source_pool”:

# du -sh /source_pool
9.0G /source_pool


We know that flat file copy tools like tar are out of the question. Prior to discovering “zfs send -R", I felt we’d painted ourselves into a corner but it turns out the whole pool can be replicated as follows:

# zfs snapshot -r source_pool@backup
# zfs send -R source_pool@backup | zfs receive -F -d target_pool


This works, even though “target_pool” is smaller than “source_pool”. Once I have removed the backup snapshots from both pools, I have exactly what I wanted:

# zfs list
NAME USED AVAIL REFER MOUNTPOINT
source_pool 1.00G 2.91G 32K /source_pool
source_pool/copy1 0 2.91G 1.00G /source_pool/copy1
source_pool/copy2 0 2.91G 1.00G /source_pool/copy2
source_pool/copy3 0 2.91G 1.00G /source_pool/copy3
source_pool/copy4 0 2.91G 1.00G /source_pool/copy4
source_pool/copy5 0 2.91G 1.00G /source_pool/copy5
source_pool/copy6 0 2.91G 1.00G /source_pool/copy6
source_pool/copy7 0 2.91G 1.00G /source_pool/copy7
source_pool/copy8 0 2.91G 1.00G /source_pool/copy8
source_pool/image 1.00G 2.91G 1.00G /source_pool/image
source_pool/image@final 0 - 1.00G -
target_pool 1.00G 976M 31K /target_pool
target_pool/copy1 0 976M 1.00G /target_pool/copy1
target_pool/copy2 0 976M 1.00G /target_pool/copy2
target_pool/copy3 0 976M 1.00G /target_pool/copy3
target_pool/copy4 0 976M 1.00G /target_pool/copy4
target_pool/copy5 0 976M 1.00G /target_pool/copy5
target_pool/copy6 0 976M 1.00G /target_pool/copy6
target_pool/copy7 0 976M 1.00G /target_pool/copy7
target_pool/copy8 0 976M 1.00G /target_pool/copy8
target_pool/image 1.00G 976M 1.00G /target_pool/image
target_pool/image@final 0 - 1.00G -