# Migrating ZFS/root Data



## gkontos (Aug 14, 2010)

Hi everybody,

I currently run at home two 8.1 boxes both with ZFS/mirror root using GPT. I need to swap the drives from both boxes while maintaining the data. I was thinking of sending a snapshot on an external drive from both boxes. Swap the disks, boot in fix it mode and then receive the snapshots back to the new disks. Does that sound feasible ?

BOX#1

```
NAME                        USED  AVAIL  REFER  MOUNTPOINT
zroot                      10.2G  63.1G   783M  legacy
zroot/swap                    2G  65.1G    16K  -
zroot/tmp                  7.18M  63.1G  7.18M  /tmp
zroot/usr                  7.31G  63.1G  6.34G  /usr
zroot/usr/home              296M  63.1G   296M  /usr/home
zroot/usr/ports             393M  63.1G   393M  /usr/ports
zroot/usr/ports/distfiles    31K  63.1G    31K  /usr/ports/distfiles
zroot/usr/ports/packages     18K  63.1G    18K  /usr/ports/packages
zroot/usr/src               302M  63.1G   302M  /usr/src
zroot/var                   121M  63.1G  14.8M  /var
zroot/var/crash            19.5K  63.1G  19.5K  /var/crash
zroot/var/db                105M  63.1G  84.9M  /var/db
zroot/var/db/pkg           19.9M  63.1G  19.9M  /var/db/pkg
zroot/var/empty              18K  63.1G    18K  /var/empty
zroot/var/log               260K  63.1G   260K  /var/log
zroot/var/mail               19K  63.1G    19K  /var/mail
zroot/var/run                79K  63.1G    79K  /var/run
zroot/var/tmp               644K  63.1G   644K  /var/tmp
```
BOX#2

```
NAME                        USED  AVAIL  REFER  MOUNTPOINT
zroot                      32.9G   195G   542M  legacy
zroot/swap                    2G   197G    16K  -
zroot/tmp                  69.5K   195G  69.5K  /tmp
zroot/usr                  30.1G   195G  2.83G  /usr
zroot/usr/export           26.7G   195G    23K  /usr/export
zroot/usr/export/SONY-HDD  19.2G   195G  9.61G  /usr/export/SONY-HDD
zroot/usr/export/gotos      512M   195G   270M  /usr/export/gotos
zroot/usr/export/kitos      304M   195G   152M  /usr/export/kitos
zroot/usr/export/photos    6.66G   195G  3.33G  /usr/export/photos
zroot/usr/home             68.5K   195G  68.5K  /usr/home
zroot/usr/ports             269M   195G   268M  /usr/ports
zroot/usr/ports/distfiles    18K   195G    18K  /usr/ports/distfiles
zroot/usr/ports/packages     18K   195G    18K  /usr/ports/packages
zroot/usr/src               303M   195G   303M  /usr/src
zroot/var                   307M   195G   118M  /var
zroot/var/crash            19.5K   195G  19.5K  /var/crash
zroot/var/db                169M   195G   164M  /var/db
zroot/var/db/pkg           5.18M   195G  5.18M  /var/db/pkg
zroot/var/empty              18K   195G    18K  /var/empty
zroot/var/log              19.8M   195G  19.8M  /var/log
zroot/var/mail              225K   195G   225K  /var/mail
zroot/var/run              65.5K   195G  65.5K  /var/run
zroot/var/tmp               106K   195G   106K  /var/tmp
```

As you can see both have identical set up. The only difference is in the disk sizes and speed.

Thanks,
George


----------



## gkontos (Aug 15, 2010)

First steps would be to create snapshots of the current mountpoints:

```
zfs snapshot zroot/@1
zfs snapshot zroot/usr@1
zfs snapshot zroot/var@1
```
Then send them to the external drive:

```
zfs send zroot/@1 > /backup/box1/root
zfs send zroot/usr@1 > /backup/box1/usr
zfs send zroot/var@1 > /backup/box1/var
```
So far I have snapshots of "/", "/usr" and "/var". I will be creating a new tmp and swap so I don't need to save those.
My current concern is how to receive the root snapshot on the new system. Assuming that the new system is set up with an identical zroot pool then I would have to:

```
zfs receive zroot/@1 < /backup/box1/root
zfs receive zroot/usr@1 < /backup/box1/usr
zfs receive zroot/var@1 < /backup/box1/var
```
In theory would give me an identical system.


----------

