Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've been doing a bit of reading, and it looks like ZFS doesn't like disks being removed from non-redundant arrays:

You can use the zpool detach command to detach a device from a mirrored storage pool. For example:

# zpool detach zeepool c2t1d0

However, this operation is refused if there are no other valid replicas of the data. For example:

# zpool detach newpool c1t2d0
cannot detach c1t2d0: only applicable to mirror and replacing vdevs

The basic problem is understandable: removing the only copy of a piece of data (whether metadata or payload data) from an array would render that data unavailable.

The examples for replacing devices in a ZFS storage pool give a basic step-by-step description for how to replace a device in a storage pool: offline the disk, remove the disk, insert the replacement disk, run zpool replace to inform ZFS of the change and online the disk. This obviously requires that the array does not depend on the disk being replaced, hence the array must have redundancy; if it does depend on the drive in question, this approach presents the same problem as above.

What is the recommended way of replacing a disk in a non-redundant ZFS array?

Assume that the existing disk is working properly, and assume that the replacement disk is at least the same size as the disk being replaced. (If the existing disk has failed, clearly all one could do is add a new disk and restore all files affected by the disk failure from backup.)

share|improve this question

1 Answer 1

up vote 7 down vote accepted
zpool attach pool old-disk new-disk

That will convert old-disk into a mirror with both old-disk and new-disk and start resilvering after which you can detach the old disk.

zpool detach pool old-disk

Tested with loop devices:

# truncate -s 1G a b
# truncate -s 1200M c
# losetup  /dev/loop0 a
# losetup  /dev/loop1 b
# losetup  /dev/loop2 c
# zpool create test loop{0,1}
# zpool attach test loop1 loop2
# zpool status
      pool: test
 state: ONLINE
  scan: resilvered 62K in 0h0m with 0 errors on Wed Jul 31 13:43:19 2013
config:

        NAME        STATE     READ WRITE CKSUM
        test        ONLINE       0     0     0
          loop0     ONLINE       0     0     0
          mirror-1  ONLINE       0     0     0
            loop1   ONLINE       0     0     0
            loop2   ONLINE       0     0     0
# zpool detach test loop1
# zpool status
  pool: test
 state: ONLINE
  scan: resilvered 62K in 0h0m with 0 errors on Wed Jul 31 13:43:19 2013
config:

        NAME        STATE     READ WRITE CKSUM
        test        ONLINE       0     0     0
          loop0     ONLINE       0     0     0
          loop2     ONLINE       0     0     0
share|improve this answer
    
So you're saying that ZFS doesn't support such an operation natively? Seems weird. (It would seem that all that's needed is to have both drives connected and then inform ZFS that the old drive is about to be taken offline, thus giving it a chance to migrate the data on it to other drives much the same as would be done if that was a resilvering in a redundant array.) –  Michael Kjörling Jul 31 '13 at 12:04
    
@MichaelKjörling, I'm not saying that. I just say the above should work as I can't see any reason why it shouldn't. –  Stéphane Chazelas Jul 31 '13 at 12:41
    
Having said that, it looks like ZFS supports it indeed. Answer updated. –  Stéphane Chazelas Jul 31 '13 at 12:51
    
Great! This is the kind of answer I was looking for and hoping to get. Would give you another +1 for trying it out if I could. –  Michael Kjörling Jul 31 '13 at 13:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.