complete clone/restore from a ZFS-based system replication stream

Mike Tancsa mike at
Mon Sep 26 17:34:29 UTC 2016

On 9/26/2016 11:47 AM, Victor Sudakov wrote:
> Dear Colleagues,
> I have a complete dump of a working system created by 
> 'zfs send -Rv zroot at test1 > test1.zfs '. I think it's called a
> replication stream package. I also have a new hard drive.  Then I
> create the freebsd-boot, freebsd-swap and freebsd-zfs partitions on
> the new drive, install the bootloader on it.
> Now what command exactly do I use to restore the system from
> test1.zfs? I have tried "zfs receive" with different combinations of
> options but each time I and with some error message like "destination
> exists..."
> Please refer me to a good howto on restoring a system from a
> replication stream package.

Here are the steps I used to restore a "level zero" zfs file onto a
new/fresh mirror.

gpart destroy -F ada0
gpart destroy -F ada1
gpart create -s gpt ada0
gpart create -s gpt ada1
gpart add -s 222 -t freebsd-boot ada0
gpart add -s 222 -t freebsd-boot ada1
gpart add -s 8g -t freebsd-swap ada0
gpart add -s 8g -t freebsd-swap ada1
gpart add -t freebsd-zfs -s 400g ada0
gpart add -t freebsd-zfs -s 400g ada1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1

#make sure /mnt2 exists
zpool create -f -o altroot=/mnt2 -O canmount=off -m none zroot mirror
/dev/ada0p3 /dev/ada1p3

gzcat /mnt/zroot-.0.gz  | zfs recv -vF zroot
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada1

#import it, but its probably already there so dont worry about the error
zpool import -f -o altroot=/mnt2  zroot
zpool set bootfs=zroot/ROOT/default zroot

... You should now be able to boot off the restored mirror.


Mike Tancsa, tel +1 519 651 3400
Sentex Communications, mike at
Providing Internet services since 1994
Cambridge, Ontario Canada

More information about the freebsd-questions mailing list