Home » Fixes » ZFS and ZPool – Migrate a Stripe Set to a Mirror (RAID 0 to RAID 1)

ZFS and ZPool – Migrate a Stripe Set to a Mirror (RAID 0 to RAID 1)

Microchip

Basic Information

ZFS is a modern file system with a lot of cool features, like encryption, handling very big volumes, providing data integrity (bit rot prevention) and high performance. Originally ZFS was developed by Sun Microsystems.


The Problem

Recently I had the problem to migrate a ZFS RAID 0 (Stripe Set) consisting in two disks to a ZFS RAID 1 (Mirror). The aim was to avoid data loss and downtime of my system. I was searching in the internet but no solution was found by me.

Before I tried to fix the problem on the production system, I created a lab environment with two USB sticks and tested the procedure. The following steps were done with two USB Sticks on a Ubuntu PC.

The USB sticks are show on my Ubuntu PC as the devices /dev/sdb and /dev/sdc.


Step 1 – Creating the ZFS ZPool

First I created a single disk ZPool with the following command:

zpool create tank /dev/sdc 

The name of the ZPool is “tank” and the first USB stick I added was the one which appeared as /dev/sdc.


Step 2 – Creating the ZFS Stripe Set

Then I added a second disk to the ZPool. The following command created a Stipe Set consisting in /dev/sdc and /dev/sdb:

zpool add tank /dev/sdb

Now I had the same situation on my Ubuntu PC like on my production system: Just a Strip Set.


Step 3 – Removing a Disk from the ZFS Strip Set

Now the interesting part started. Removing the device /dev/sdb from the Strip Set.

zpool remove tank /dev/sdb

The procedure took some time to complete. I just executed “zpool status” and observed the progress.

If there is enough space left on the remaining disk to keep all original data it should be just fine and the procedure should work.


Step 4 – Creating the ZFS Mirror

The goal was near – just added a disk to the single disk ZPool. With the “attach” option a mirror (RAID 1) is created out of the devices “/dev/sdb” and /dev/sdc”:

zpool attach -f tank  /dev/sdb /dev/sdc

Conclusion

Please keep in mind that this procedure works only if the Strip Set is not too full. The remaining disk in the Strip Set (Step 3) needs to have enough capacity to keep the original Strip Set data alone.

That’s it – have fun!


Leave a comment

Your email address will not be published. Required fields are marked *

consulting picture

WordPress Cookie Notice by Real Cookie Banner