# Adding ZFS mirror of root-on-ZFS after FreeBSD install



## bra1n (Dec 29, 2014)

Greetings,

I installed FreeBSD 10.1 on what used to be a Linux file server with two identical 3TB hard disks: a primary, boot drive and a drive containing file system backups done via rsync . I chose to set up FreeBSD with root-on-ZFS on the boot drive, then mount my backup drive with ext4fuse and sync my data back onto the boot drive.

My question is now can I somehow add the backup drive in as a mirror of the boot drive? And if so is there a guide somewhere on how to do it?  I'm new to ZFS and haven't found much online that seems to apply to this particular case.  I may be better off doing nightly rsyncs like I was, so that if I accidentally delete a file on the boot drive I have until the nightly rsync to retrieve it from the backup drive.

Any advice would be greatly appreciated!

-brian


```
[
root@x:~ # freebsd-version

10.1-RELEASE-p3

root@x:~ # uname -a

FreeBSD x 10.1-RELEASE FreeBSD 10.1-RELEASE #0 r274401: Tue Nov 11 21:02:49 UTC 2014     root@releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64

root@x:~ # gpart show

=>        34  5860533101  ada0  GPT  (2.7T)

          34        2014        - free -  (1.0M)

        2048  5860530176     1  ms-basic-data  (2.7T)

  5860532224         911        - free -  (456K)


=>        34  5860533101  diskid/DISK-MK0311YHG0KKNA  GPT  (2.7T)

          34        2014                              - free -  (1.0M)

        2048  5860530176                           1  ms-basic-data  (2.7T)

  5860532224         911                              - free -  (456K)


=>        34  5860533101  ada1  GPT  (2.7T)

          34        1024     1  freebsd-boot  (512K)

        1058     4194304     2  freebsd-swap  (2.0G)

    4195362  5856337773     3  freebsd-zfs  (2.7T)


=>      0  8028160  da2  BSD  (3.8G)

        0   470720    1  freebsd-ufs  (230M)

  470720  7557440       - free -  (3.6G)


=>      0  8028160  diskid/DISK-037FF541  BSD  (3.8G)

        0   470720                     1  freebsd-ufs  (230M)

  470720  7557440                        - free -  (3.6G)
/CODE]
```


----------



## SocialHaze (Dec 29, 2014)

If you read zpool(8), you should be able to understand how ZFS handles mirrors.


----------



## bra1n (Dec 29, 2014)

I was eyeballing

`zpool attach pool device new_device`

which would seem to create a 2 way mirror.


```
root@x:~ # zpool status

  pool: zroot

state: ONLINE

  scan: none requested

config:


NAME        STATE     READ WRITE CKSUM

zroot       ONLINE       0     0     0

  gpt/zfs0  ONLINE       0     0     0


errors: No known data errors
```
Now I'm looking at zeroing out the backup disk and using gpart to create a new device zfs1 and then attaching it to the existing pool zroot.  I'm just concerned that the price for failure is high here as I only have these two disks with copies of my data on them.  How do I know that the blank zfs1 won't overwrite zfs0 with its emptiness?  Or am I going in completely the wrong direction?

Thanks!


----------



## bra1n (Dec 30, 2014)

NVM.  It looks like someone posted a solution at https://forums.freebsd.org/threads/howto-convert-single-disk-zfs-on-root-to-mirror.49702/


----------

