How to Convert a Stripe into a Mirror in FreeNAS

Ideally, with FreeNAS, if you plan on using mirrored drives, you should start directly with 2 physical drives. This holds for every combination of drives actually, because modifying existing vdevs is not allowed (you can only add new vdevs to an existing zpool).

The only exception consists in converting a striped vdev into a mirrored vdev. In my case, I started using FreeNAS in a test machine with a single physical drive, but then decided to add a second drive to keep testing it a little bit more thoroughly. Obviously, one solution consisted in taking a copy of my data, wipe out both disks, create a mirror vdev and then reimport the data from the backup, but why go through the hassle when you can do this quickly and easily from the CLI?

These instructions are taken from a post on the official FreeNAS forum. I have decided to include them here because there are several discussions on the topic on the forum, but not all of them include comprehensive instructions on how to do this.

gpart create -s gpt /dev/ada1
gpart add -i 1 -b 128 -t freebsd-swap -s 2g /dev/ada1
gpart add -i 2 -t freebsd-zfs /dev/ada1

Run

zpool status

and note the gptid of the existing disk
Run

glabel status

and find the gptid of the newly created partition. It is the gptid associated with ada1p2.

zpool attach tank /dev/gptid/[gptid_of_the_existing_disk] /dev/gptid/[gptid_of_the_new_partition]

In FreeNAS, hard drives are normally named ada<n>, with <n> starting from 0 and being incremented by one every time a new hard drive is added. Therefore, if you are only using one hard drive and want to add a second one, your new drive will likely be called ada1.

Also, replace tank with your zpool name.

I vehemently recommend testing this in a virtualized environment before attempting it on your physical system. Dealing with vdevs and zpools is a delicate operation, and you really don’t want to risk losing your data just because of a wrong command.

Note: if the new hard drive already contains some data, you need to wipe it first. This can be easily done from the GUI:

If everything went fine, you should see the resilvering process take place after running a zpool status:

1429970946_thumb.png

And at the end of the resilvering process you should see something like this:

Screenshot 2015-04-25 16.26.37

7 Comments

  1. Just followed your instructions Daniel. Thank you very much. I ‘think’ all is working… so far. I have added a 2nd 3Tb hard drive to my NAS and wanted to mirror the original one in there. The Alert button is showing a flashing red on the Freenas homepage and it informs me that resilvering is in process. Also when I type in ‘zpool status’ it confirms this too.
    Can I ask, when this completes will I get access to that second drive from my Windows/File Explorer?

    • Hey Andy :) That sounds correct, FreeNAS will tell you that the resilvering is in process, and for a 3 TB hard drive it will take a few hours so no worries.

      Because you transformed a single drive into a mirror, you will not see this second drive in Windows Explorer, things will continue showing up as before for you: you will only see your volume, the fact that this volume is stored on a mirror for redundancy is abstracted from you by the operating system.

      • Thanks Daniel. It did indeed stop ‘resilvering’ as you said. As a Freenas/Linux noob it does somewhat bug me how I can’t see what’s on the new hard drive. :D
        So if my original drive (that I can see the files on) was to stop working, and I put in a new replacement one, would Freenas just automatically start copying over these files from the mirror drive until it’s completely done? Also, on each occasion I send a file over to the nas is it now automatically mirrored?

        Really sorry for asking you all this, but as I hardly know a thing about anything outside of Windows I’m clueless! Although I have been working it all out slowly. i.e. Installed and running a Minecraft server and using Nextcloud with my phone. :)

        Cheers.

        • Not a problem at all mate, we all have to start somewhere :D

          The reason why you cannot see the new drive as a separate drive is because you configured the drives as mirrors, which means that the new drive is the exact copy of the old one. Effectively, from the user’s perspective, this is really just a single drive. This is why Windows doesn’t show you how many drives are behind a mirror, it’s FreeNAS who handles all the operations (indeed, you can see both drives from the FreeNAS GUI).

          Mirrors give you redundancy in that when one of the drives fails, you can still access your data because the other drive in the mirror holds a complete copy of everything. This is what the resilvering process basically does. When a drive fails, you can replace it with a new one and start the resilvering once more (you need to start this yourself, it doesn’t automatically start after you put in the new drive):

          http://doc.freenas.org/9.3/freenas_storage.html#replacing-a-failed-drive

          If you want to get the additional free space coming from an additional drive, mirrors are not the way to go ;)

          Also, funny you mentioned Nextcloud. I am currently running ownCloud and I have been thinking about giving Nextcloud a try, I definitely need to do that when I have some time.

          • When I read up on ownCloud I was going to use it until I read something somewhere about how the people behind it were taken over by another business and 90% of the team left and went on to create NextCloud. So after reading that I just decided to take that route as I get the feeling it might get more support!? Both seem the business though. Well chuffed with using NextCloud. Certainly a great way to backup photos from my phone with no effort and without having to pay for online cloud services. (which I have done in the past)

            Thanks for all your help on this Daniel. It is very much appreciated. I look on forums all the time, but unfortunately on most occasions they all talk in Linux babble mode and I’m totally lost! lol. Guess I must be a Windows-fanboy! :D

          • Yep, that’s right. That’s one of the reasons I started thinking about Nextcloud :) I am currently syncing my photos to my Plex server but I suppose having an extra copy of those on own/Nextcloud won’t hurt.

            And you are very welcome Sir, my pleasure! I get where you are coming from re forums, been there done that lol. Do keep in touch :)

  2. Will be popping back from time to time Daniel. Nice one. :D

Leave a Reply

© 2017 Daniel's TechBlog

Theme by Anders NorénUp ↑

%d bloggers like this: