Is it possible to turn a single disk volume into a ZFS mirror?

Status
Not open for further replies.
Joined
Oct 31, 2012
Messages
29
I had a ZFS mirror (2x 1.5TB HDD) up and running until one of the drives in the volume became ‘unavailable’. I tried all sorts of things to get it back online, but it wanted me to replace it. In the end, I detached the disk from the volume, leaving me with a single disk and no mirror.

I can now see that the disk is available to use again. However, how can I add it to the volume to get my mirror back?

Appreciate any help!
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I might be wrong here but I think you need to completely erase the drive, from heel to toe. I believe there is some sort of marker on the drive which lets the NAS know it's part of a pool. I also think you can run a command from the console to do it while the drive is attached to the machine, I just don't know what that is off the top of my head. Maybe you could search for this as I have seen this question several times before.

The other option is to rebuild your mirror and may be the fastest option.

EDIT: Make sure you backup your data before doing anything!
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
First I'd try plugging the drive back into the FreeNAS machine and see if it becomes part of the zpool again. If it does you should be able to do a scrub and all is fixed.

If it doesn't become part of the zpool again then you'll need to zero out the drive. Theres some info for the ZFS pool located at the beginning and end of the drive. The way I usually do it is just zero out the entire drive. I'm sure someone somewhere has some easy commands that will allow you to zero out the applicable parts of the hard drive without waiting for the few hours(maybe more) for the drive to zero out completely.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
First I'd try plugging the drive back into the FreeNAS machine and see if it becomes part of the zpool again. If it does you should be able to do a scrub and all is fixed.

If it doesn't become part of the zpool again then you'll need to zero out the drive. Theres some info for the ZFS pool located at the beginning and end of the drive. The way I usually do it is just zero out the entire drive. I'm sure someone somewhere has some easy commands that will allow you to zero out the applicable parts of the hard drive without waiting for the few hours(maybe more) for the drive to zero out completely.

I agree, there is some set of instructions burried in these forums about how to erase the front and back tracks of the drive. I tried a search last night but came up empty handed but I have seen it, probably ~2 years ago when this all kicked off and people had all kinds of problems.
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Oliver,

There is a way to convert a stripe to a mirror. It is in the FreeNAS manual. Sorry I'm not more specific since I'm not at home and I haven't done it before. But I do know that converting a stripe to a mirror is the ONLY vdev change you can actually do! It's the one exception to the rule.
 
Joined
Oct 31, 2012
Messages
29
Oliver,

There is a way to convert a stripe to a mirror. It is in the FreeNAS manual. Sorry I'm not more specific since I'm not at home and I haven't done it before. But I do know that converting a stripe to a mirror is the ONLY vdev change you can actually do! It's the one exception to the rule.

I’ve spent quite a while searching but I can’t seem to find this in the manual. Could you mind pointing me to the right place when you get a moment?
 

Stephens

Patron
Joined
Jun 19, 2012
Messages
496

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
Assuming the drive not part of the pool is ada0:

Code:
gpart create -s gpt ada0

gpart add -i 1 -t freebsd-swap -s 2G ada0

gpart add -i 2 -t freebsd-zfs ada0
Followed by:
Code:
zpool attach Volume1 ada1p2 ada0p2
 
Joined
Oct 31, 2012
Messages
29
Assuming the drive not part of the pool is ada0:

Followed by:
Code:
zpool attach Volume1 ada1p2 ada0p2

Hmm, I’m getting this:

Code:
[root@FreeNAS /mnt/Volume1]# gpart create -s gpt /dev/ada0ada0
created
[root@FreeNAS /mnt/Volume1]# gpart add -i 1 -t freebsd-swap -s 2G ada0ada0p1
added
[root@FreeNAS /mnt/Volume1]# gpart add -i 2 -t freebsd-zfs ada0
ada0p2 added
[root@FreeNAS /mnt/Volume1]# zpool attach Volume1 ada1p2 ada0p2
cannot attach ada0p2 to ada1p2: no such device in pool
[root@FreeNAS /mnt/Volume1]# 


EDIT: Never mind. I ran `zpool status`, grabbed the ID of the disk already in the pool, and then ran it through the command:

Code:
[root@FreeNAS ~]# zpool attach Volume1 gptid/5ca36b77-2864-11e2-bbc0-d43d7e27f14a ada0p2


Seems to have worked! Can you tell me why that disk has such a long ID compared to the one we just formatted? How can I check that this has indeed mirrored? I guess it will be transferring data onto the disk as we speak (resilvering?): http://cl.ly/image/3l0J00171A1Z.

Thanks a lot for your help. Perhaps you could talk me through the process with those commands so I can learn something? :D
 

Stephens

Patron
Joined
Jun 19, 2012
Messages
496
You can always google the commands.
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
You can always google the commands.
Or simply read the man pages.

Thanks a lot for your help. Perhaps you could talk me through the process with those commands so I can learn something? :D
The first set partitions the drive like the GUI would do. The zpool attach also seems straightforward. Refer to the man pages to understand exactly what they do and their syntax.

Seems to have worked! Can you tell me why that disk has such a long ID compared to the one we just formatted?
8.2 and above uses the gptid instead of the device name. Devices names can & do change whereas the gptid shouldn't. To map gptid to device name:
Code:
glabel status
A reboot or export/import should "fix" ada0p2 to use its gptid.

How can I check that this has indeed mirrored?
Code:
zpool status -v
You could have made the whole process less painful by having offlined the drive instead of detaching it. Then you would simply issue a:
Code:
zpool online pool device


FYI, 8.2 and up includes a disk wipe facility in the GUI. AFAIK, it works quite well.
 
Joined
Oct 31, 2012
Messages
29
Or simply read the man pages.

The first set partitions the drive like the GUI would do. The zpool attach also seems straightforward. Refer to the man pages to understand exactly what they do and their syntax.

8.2 and above uses the gptid instead of the device name. Devices names can & do change whereas the gptid shouldn't. To map gptid to device name:
Code:
glabel status
A reboot or export/import should "fix" ada0p2 to use its gptid.

Code:
zpool status -v
You could have made the whole process less painful by having offlined the drive instead of detaching it. Then you would simply issue a:
Code:
zpool online pool device


FYI, 8.2 and up includes a disk wipe facility in the GUI. AFAIK, it works quite well.

Hmm. My volume has gone into degraded status again.

It was online, but I had this error:
Code:
status: One or more devices has experienced an unrecoverable error.  An attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors using 'zpool clear' or replace the device with 'zpool replace'.


See: http://hastebin.com/kihaqaweki.vhdl

So I run `zpool clear Volume1` and now one of my disks is ‘unavailable’.

See: http://hastebin.com/sosoreyuyi.vhdl

As you can see, I tried to run `zpool online` to bring it back, but it’s still unavailable. This is what happened last time, so I ended up detaching the disk and resilvering. Would like to avoid that this time – not sure why I keep running into this.

Any help will be appreciated!
 

cyberjock

Inactive Account
Joined
Mar 25, 2012
Messages
19,526
Shameless bump.. those links don't work!

But if you have a disk that is offlined/unavailable you WILL be doing a resilver/scrub. There's no way around it since the drive is no longer in sync with the rest of the zpool.

If the same drive is causing these problems with going offline/unavailable it sounds like you have a disk that is going bad. You should run SMART tests on it and see how the results are.
 
Status
Not open for further replies.
Top