Zpool-remove or create new pool (to go from 2 to 1 vdev)?

Hello !

Here is my current setup: I have 2 2-disks vdevs in my pool:

tank
  mirror-0
    disk-6TB-0
    disk-6TB-1
  mirror-1
    disk-3TB-0
    disk-3TB-1

I want to switch to a 2 disks setup (i.e. a single mirror of 2 disks).
The 2 disks will be new ones (18TB each).

Hence, I want the final setup to look like this:

tank
  mirror-0
    new-disk-18TB-0
    new-disk-18TB-1

Note: none of the old disks are present in the new setup.

My question: How to get from the current setup to the new one ?

I see 2 options:

  • Option A1: As the total used space is currently < 6TB:
    • zpool remove tank mirror-1
    • Replace the 6TB disks of mirror-0 one by one with the new 18TB disks
  • Option A2: (similar to A1, just the other way around. I don’t know if it is better, worse or same.)
    • Replace the 6TB disks of mirror-0 one by one with the new 18TB disks
    • zpool remove tank mirror-1
  • Option B:
    • Create a separate new pool with a single mirror vdev containing the two new 18TB disks
    • “Migrate”/“copy”/“clone” the old pool to the new one. (With something like zfs send | zfs receive)

What are the pros and cons of both solutions ?
Have I missed something ?

Thank you in advance for your help !

If you have the spare SATA ports, I would always use zfs send | zfs receive . This is one of the exact use-cases it’s designed for, and it will write the data nice and evenly on the receiving end.

I have a similar setup but I want to release the two disks in a 2 x 2 disk mirror vdev zpool.

zpool list -v
NAME                                                 SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
tank                                                21.8T  11.0T  10.8T        -         -     8%    50%  1.00x  
  mirror-0                                          5.45T  2.31T  3.14T        -         -     5%  42.4%      -    ONLINE
    ata-ST6000VN001-A                               5.46T      -      -        -         -      -      -      -    ONLINE
    ata-ST6000VN001-B                               5.46T      -      -        -         -      -      -      -    ONLINE
  mirror-1                                          16.4T  8.67T  7.69T        -         -     9%  53.0%      -    ONLINE
    ata-ST18000NT001-C                              16.4T      -      -        -         -      -      -      -    ONLINE
    ata-ST18000NT001-D                              16.4T      -      -        -         -      -      -      -    ONLINE

I have enough space in mirror-1 so I’d like to remove mirror-0. Are there any downsides to zpool remove tank mirror-0?

I did a dry run:

zpool remove -n tank mirror-0
Memory that will be used after removing mirror-0: 45.6M

BTW what’s the etiquette here? I searched for zpool remove and this thread had my question but it wasn’t fully answered so I jumped onto it. Would it have been better to create a new thread?

Unless I’m wrong about what zpool remove <pool> mirror-x would do, you would be losing your data.

tank                        5.50G   958M  4.56G        -         -     0%    17%  1.00x    ONLINE  -
  mirror-0                  2.75G   474M  2.29G        -         -     0%  16.8%      -    ONLINE
    disk-0                  3.00G      -      -        -         -      -      -      -    ONLINE
    disk-2                  3.00G      -      -        -         -      -      -      -    ONLINE
  mirror-1                  2.75G   484M  2.28G        -         -     0%  17.2%      -    ONLINE
    disk-1                  3.00G      -      -        -         -      -      -      -    ONLINE
    disk-3                  3.00G      -      -        -         -      -      -      -    ONLINE

Everything on disk-0 is mirrored on disk-2, and everything on disk-1 is mirrored on disk-3. The data is striped across mirror-0 and mirror-1. Removing either mirror-0 or mirror-1 would result in half of the pool missing.

If you want to remove disks, you would want to detach disk-2 from disk-0, and detach disk-3 from disk-1

Edit: Looks like removing a mirror moves the data from the removed vdev to the remaining vdev(s).
The result looks like this (tested with loop devices):

tank                        2.75G   958M  1.81G        -         -     1%    34%  1.00x    ONLINE  -
  mirror-0                  2.75G   958M  1.81G        -         -     1%  34.0%      -    ONLINE
    disk-0                  3.00G      -      -        -         -      -      -      -    ONLINE
    disk-2                  3.00G      -      -        -         -      -      -      -    ONLINE
  indirect-1                    -      -      -        -         -      -      -      -    ONLINE

Don’t do it. If you do, every single block that was stored on the removed vdev will now have an indirection link to it. When you ask for those blocks, you’ll still ask for them on the missing vdev, the pool will do a lookup to see that block has moved to the remaining vdev, and THEN you’ll get the actual block.

You’ll also have noticeably undersized metaslabs on that one vdev, if you replace 6TB drives with 18TB drives. The metaslab size is determined at vdev creation time and never updated. This is probably not going to be a big enough deal to matter, if it were only a case of “I need to expand this one vdev from 6TB drives to 18TB drives,” but you’ve got more going on here than that.

In contrast to all this, if you simply set up a new pool with a single mirror vdev and then replicate all your data in, you’ll have the proper sized metaslabs for your big new drives, you won’t have any weird indirect links, everything will just be perfectly nice the way it’s meant to be.

1 Like

Thanks for explaining that, so it’s not just a small memory overhead!
I only have four sata ports available so would you break the 18tb mirror such that I can create a new zpool with a single 18TB drive and then replicate tank to that. Once done, destroy tank and attach the other 18TB drive? Now I have my two 6TB drives and a single mirror zpool. This is my backup device so worst case scenario I could replicate from prod and just lose some older snapshots.

Yup, that’s exactly right. Don’t forget to scrub the pool before breaking one of the mirrors. Then scrub the new pool after you finish replicating, before you destroy the old one.