# Moving FreeBSD from UFS to a mirrored ZFSroot



## ser22 (Jul 7, 2021)

Hi all! 

I recently installed FreeBSD using some old hardware I got my hands on


```
% uname -a
FreeBSD sparky 13.0-RELEASE-p1 FreeBSD 13.0-RELEASE-p1 #0: Wed May 26 22:15:09 UTC 2021
```

Nothing fancy, just a small boot disk and a 3 disk ZFS raidz


```
% gpart show ada0
=>       40  976773088  ada0  GPT  (466G)
         40       1024     1  freebsd-boot  (512K)
       1064  968883192     2  freebsd-ufs  (462G)
  968884256    7888872     3  freebsd-swap  (3.8G)
```

I installed sysutils/iocage and created some jails (FAMP stack) in order to learn more about it.
Because I don't trust very much the old disks I'm using, I thought it could be interesting to add a second disk and mirror both as described here.

At this stage, reinstalling from scratch wouldn't be a problem, but I'm curious how other users with more experience would approach such a migration, best practices, etc.

I have a Linux background, but I'm trying to escape the distro nightmare


----------



## olli@ (Jul 7, 2021)

In your situation it is probably best to use the FreeBSD installer and let it install a ZFS-based boot disk. This will do all the steps automatically.

Note that the wiki page that you mentioned is more than 4 years old and refers to an older version of FreeBSD + ZFS. Some things have changed and should be done differently today. For example, gptzfsboot is for legacy BIOS _only_. Even if you have old hardware that uses legacy BIOS for booting, it is probably a good idea to install a system in a way that supports UEFI booting, in case you move the disk to a newer PC some day, so you don’t have to reinstall again.


----------



## ser22 (Jul 8, 2021)

olli@ said:


> In your situation it is probably best to use the FreeBSD installer and let it install a ZFS-based boot disk. This will do all the steps automatically.
> 
> Note that the wiki page that you mentioned is more than 4 years old and refers to an older version of FreeBSD + ZFS. Some things have changed and should be done differently today. For example, gptzfsboot is for legacy BIOS _only_. Even if you have old hardware that uses legacy BIOS for booting, it is probably a good idea to install a system in a way that supports UEFI booting, in case you move the disk to a newer PC some day, so you don’t have to reinstall again.



You're right olli@ 

I checked again, and the FreeBSD installer is indeed capable of creating a mirrored zroot out of the box as I wanted.


```
% zpool status
  pool: tank
 state: ONLINE
config:

    NAME        STATE     READ WRITE CKSUM
    tank        ONLINE       0     0     0
      ada0      ONLINE       0     0     0
      ada1      ONLINE       0     0     0
      ada2      ONLINE       0     0     0

errors: No known data errors

  pool: zroot
 state: ONLINE
config:

    NAME        STATE     READ WRITE CKSUM
    zroot       ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        ada3p3  ONLINE       0     0     0
        ada4p3  ONLINE       0     0     0

errors: No known data errors
```

I just need now to explore the best way of "moving" my previous setup, including the iocage jails, to this new layout.


----------



## ccammack (Jul 8, 2021)

If you are short on drives, you can also install ZFS using the installer to a single drive "stripe," then add a second drive to create a mirror afterwards. It's easy to do.

Also, `iocage` has `export` and `import` options that have worked for me in the past.


----------

