Converting FreeBSD UFS to Linux ZFS

My FreeBSD server has an UFS gmirror with 2 disks, last week one of the disks broke, and I'm buying a new disk.

I would like to migrate this machine to Linux ZFS (reason being that I can't use pkg-ng on this machine, and ports are too slow) and thought this might be a good opportunity for this. What is the best strategy for this?

1. Mount the disk in Linux as UFS & copy. Is this reliable?
2. Create ZFS in FreeBSD, copy from UFS to ZFS. Will this ZFS also be readable in Linux? I remember my OpenSolaris ZFS not being readable in FreeBSD a few years ago...
3. Use ext4fuse, copy to new (blank) disk, boot Linux, create ZFS on UFS disk, copy again (from ext4).

I'm also thinking of maybe doing a SHA256 over all the old & new files, and check for differences...
 
I often hang myself in over-complicated procedures :D , even for simple tasks, so if I were you I probably do something (slow?) like this:
4. Install Linux + ZFS on the new disk, install FreeBSD on a virtual machine and use the UFS disk as a raw device. Then from the virtual machine transfer all data to the Linux host using any method you can think of (ssh,nfs,ftp...)
 
2. Create ZFS in FreeBSD, copy from UFS to ZFS. Will this ZFS also be readable in Linux?
ZFS is portable and that should be no problem BUT. The Linux version of ZFS is behind FreeBSD version (at least behind 10.1) and that might not work. You can import older version of ZFS pool into the newer pool but IIRC not the other way around. Also once the pool is upgraded to the new version it can't be downgraded.
 
2. Linux by default doesn't have ZFS, as you likely know, the ZFS-on-Linux version is different from the FreeBSD version. I don't know if they're going to be readable.

I have once rescued my home-folder from borked PC-BSD installation by using ZFS-on-Linux on Ubuntu 14.04. It sort of worked, not very seamless exprerience but it worked. I'd not recommend it as anything but way to rescue your files. Use native filesystems for Linux, as ZFS-on-Linux is not officially supported, it may never be officially supported, and any upgrade can break support, locking you out of your files.
 
I've done the second option mentioned in post #1 which worked fine for me, but backwards. Sharing a zpool between FreeBSD and Linux is 100% compatible as long as the ZFS version is at least 5000 and the feature flags are the same between the two operating systems.
  1. Install temporary Linux distro to portable USB flash media or like on machine.
  2. Create zpool on new disk from within temporary Linux environment, export pool and reboot.
  3. Boot back into FreeBSD, import zpool , copy over files to new pool, export pool, then again reboot.
  4. Boot back into temporary Linux environment, import pool, check to make sure everything is fantastic and if so, export pool, install permanent Linux environment to other disk, import pool, and as wblock@ says, "profit". :)
The important part is that the ZFS version being used is at least version 5000 as well as share the same feature flags between operating systems and as long as that is the case there shouldn't be any problems migrating over this way. Also, besides better file system compatibility, in doing it this way you can't corrupt any data on the good disk as FreeBSD will refuse to import the new pool to begin with if the prior mentioned requirements are not met.
 
UFS read support in Linux is stable and safe, and has been for years. It's write support that's experimental (for good reason), and it's generally necessary to recompile the kernel to even mount a UFS volume rw.
I would just add that Clonezilla is an excellent live usb/cd for that purpose, as it comes with a kernel compiled with UFS support.
  • Filesystem supported: (1) ext2, ext3, ext4, reiserfs, reiser4, xfs, jfs, btrfs of GNU/Linux, (2) FAT12, FAT16, FAT32, NTFS of MS Windows, (3) HFS+ of Mac OS, (4) UFS of FreeBSD, NetBSD, and OpenBSD, (5) minix of Minix, and (6) VMFS3 and VMFS5 of VMWare ESX. Therefore you can clone GNU/Linux, MS windows, Intel-based Mac OS, FreeBSD, NetBSD, OpenBSD, Minix and VMWare ESX, no matter it's 32-bit (x86) or 64-bit (x86-64) OS. For these file systems, only used blocks in partition are saved and restored. For unsupported file system, sector-to-sector copy is done by dd in Clonezilla.
 
If you have both machines powered on, then why not use rsync to transfer the data?

BTW. The latest ZFS on Linux does not support the feature flags of 10.1-RELEASE
 
  • Thanks
Reactions: Oko
This may seem like a dumb question, but why not backup all of your data to another drive/location, install the new OS and then restore the backup? Unless you don't have any form of external backups... in which case I'd highly recommend dealing with that first.

Also, side note: You can connect a SATA drive to a laptop using a USB connector. They only cost about $15-$20 and it makes backups/recovery so much easier. I highly recommend getting a SATA-to-USB connection.
 
Back
Top