# Cloning ZFS to another machine



## nu (Jun 11, 2012)

Hi.

I have two machines, and I try to fully clone the filesystem from the first to the second.


Primary - 9.0-RELEASE-p1 (192.168.1.1)
Secondary - booted mfsbsd-se-9.0-RELEASE-amd64. (192.168.1.11)

What I did:


```
2# mount_cd9660 /dev/acd0 /cdrom
2# zfsinstall -d ada0 -d ada1 -t /cdrom/9.0.xz -r mirror -p ZFSrootBS
2# ifconfig em0 inet 192.168.1.11 netmask 255.255.0.0 up
2# zfs list
NAME                 USED  AVAIL  REFER  MOUNTPOINT
ZFSrootBS            333M   228G    31K  none
ZFSrootBS/root       333M   228G   333M  /mnt
ZFSrootBS/root/tmp    31K   228G    31K  /mnt/tmp
ZFSrootBS/root/var   178K   228G   178K  /mnt/var
2# zfs create ZFSrootBS/cloned
```


```
1# zfs snapshot -r ZFSroot@2012-06-11
1# zfs send -R ZFSroot@2012-06-11 | ssh root@192.168.1.11 zfs recv -Fdv ZFSrootBS/cloned
```


```
2# zfs list
NAME                                   USED  AVAIL  REFER  MOUNTPOINT
ZFSrootBS                             38.6G   190G    31K  none
ZFSrootBS/cloned                      38.2G   190G  10.5G  legacy
ZFSrootBS/cloned/home                 16.1G   190G  7.87G  /mnt/home
ZFSrootBS/cloned/home/ftp             8.35M   190G  8.35M  /mnt/home/ftp
ZFSrootBS/cloned/home/mail            8.26G   190G    31K  /mnt/home/mail
ZFSrootBS/cloned/home/mail/testaa.pl  8.26G   190G  8.26G  /mnt/home/mail/testaa.pl
ZFSrootBS/cloned/tmp                   386K   190G   386K  /mnt/tmp
ZFSrootBS/cloned/usr                  10.3G   190G  5.28G  /mnt/usr
ZFSrootBS/cloned/usr/ports            4.62G   190G   300M  /mnt/usr/ports
ZFSrootBS/cloned/usr/ports/distfiles  4.33G   190G  4.33G  /mnt/usr/ports/distfiles
ZFSrootBS/cloned/usr/ports/packages     30K   190G    30K  /mnt/usr/ports/packages
ZFSrootBS/cloned/usr/src               353M   190G   353M  /mnt/usr/src
ZFSrootBS/cloned/var                  1.33G   190G  1.07G  /mnt/var
ZFSrootBS/cloned/var/crash            30.5K   190G  30.5K  /mnt/var/crash
ZFSrootBS/cloned/var/db                160M   190G   148M  /mnt/var/db
ZFSrootBS/cloned/var/db/pkg           11.3M   190G  11.3M  /mnt/var/db/pkg
ZFSrootBS/cloned/var/empty              21K   190G    21K  /mnt/var/empty
ZFSrootBS/cloned/var/log               105M   190G   105M  /mnt/var/log
ZFSrootBS/cloned/var/mail               31K   190G    31K  /mnt/var/mail
ZFSrootBS/cloned/var/run                94K   190G    94K  /mnt/var/run
ZFSrootBS/cloned/var/tmp               108K   190G   108K  /mnt/var/tmp
ZFSrootBS/root                         333M   190G   333M  /mnt
ZFSrootBS/root/tmp                      31K   190G    31K  /mnt/tmp
ZFSrootBS/root/var                     178K   190G   178K  /mnt/var
2# zfs destroy -r ZFSrootBS/cloned@2012-06-11
2# zfs set mountpoint=/ZFSrootBS ZFSrootBS/cloned
2# zpool export -f ZFSrootBS
2# zpool import -f ZFSrootBS
2# cp /boot/zfs/zpool.cache /ZFSrootBS/boot/zfs/zpool.cache
2# zfs set mountpoint=legacy /ZFSrootBS/cloned
2# zfs set mountpoint=/tmp ZFSrootBS/cloned/tmp
2# zfs set mountpoint=/var ZFSrootBS/cloned/var
2# zfs set mountpoint=/usr ZFSrootBS/cloned/usr
2# reboot
```

Some of the lines were written "by hand" but I think it's clear what I intended to do.

So, I have a problem with "legacy", files (for example /etc) are from the default FreeBSD instalation. Looks like problems with mountpoints.

What should I change/add, to fully clone a filesystem from one machine to another?

Any help would be greatly appreciated.
Thanks in advance!


----------



## Sebulon (Jun 11, 2012)

Do you know why you choose to set mountpoint=legacy? And two times, at that?

Setting it to legacy has its benefits but requires you to edit your own fstab. What is your output of:
`# cat /etc/fstab`
`# cat /etc/rc.conf`

/Sebulon


----------



## nu (Jun 12, 2012)

```
2# cat /etc/rc.conf
zfs_enable="YES"
sshd_enable="YES"
ifconfig_em0="inet 192.168.1.11 netmask 255.255.0.0"
```

fstab is empty.

I've set [cmd=]2# zfs set mountpoint=/ ZFSrootBS/cloned[/cmd] and now I have all my files (from 1#). System seems to start properly trying to run application from /etc/rc.conf, but there are some nasty error*s*.


```
internal error: failed to initialize ZFS library
```


```
devd: Can't open devctl device /dev/devctl: No such file or directory
```

After punching CTRL^C all I got is:

```
Tue Jun 12 07:20:32 CEST 2012
```
and then system freezes.

Crying for help


----------



## gkontos (Jun 12, 2012)

See if that helps.

George


----------

