# Migrating from UFS to ZFS



## chrcol (Jun 28, 2013)

Here is my plan to move from UFS single drive to ZFS mirror.

The server has two drives of equal specifications. _The seco_nd drive _is_ currently holding backups and is formatted to UFS. So something like this.

Remove data of _seco_nd drive, move backups elsewhere etc.
Create a partition to hold the ZFS data on _the seco_nd drive, not using maximum capacity of _the_ drive.  Probably around 80-90%.
Create a zpool and filesets on the drive.  The ones created would hold all files except root files, this won't be a ZFS on root.
Reboot the server into some kind of recovery mode eg. mfsBSD.
Whilst in offline recovery transfer all non root partition files to the ZFS drive. (Not sure of best command to use here to preserve perms etc.)
Configure loader.conf for ZFS.
Configure fstab for ZFS.
Reboot into ZFS system with root still be_ing_ UFS.
Reasons for not doing ZFS on root is the restrictions of not been able to expand pool, add cache/log devices.  But lose a redundant root/boot. Is there a way to duplicate _UFS_ root to _the seco_nd drive, even if manual?

At this stage is a problem that I wouldn't be able to put ZFS on the first drive without wiping the existing root partition?

So an alternative plan would be to also transfer root files to _the seco_nd HDD along with other files making that HDD the new boot device which gives freedom to convert _the fir_st drive so it can be used in a ZFS mirror.


----------



## jozze (Jul 8, 2013)

You think you can create a snapshot of the UFS root drive, but you cannot do it directly: with a LiveCD.

Start the LiveCD, when prompted for actions, choose LiveCD. When prompted for a user name use `root'. Let's say that the old root partition is /dev/ada0s2. So you run `# fsck -t ufs -y /dev/ada0s2`, and then you can mount it with `# mount -t ufs /dev/ada0s2 /mnt`. Now you can create the snapshot of your mounted filesystem, as it is described in this HOW-TO.

WARNING: On different machines, the file devices might have different names, so it's probable, that you'll have to fix the /etc/fstab afterwards, and that you'll have to reinstall the boot loader (well, boot is on a different partition to begin with).

Another thing you can do, is just use the UFS backup utilities, like dump(8)() and restore(8)(). See this HOW-TO.


----------



## wblock@ (Jul 8, 2013)

Make full, tested backups first.

Are you sure about the limitations of root on ZFS?  I'd either go all ZFS or a gmirror(8) for the operating system on a separate pair of drives.


----------

