Start a ZFS RAIDZ zpool with two discs then add a third?

19,491

Solution 1

A method some people use, but that is not recommended:

  1. Create a pool with 2 drives and a sparse file (of the right, virtual size to match the other drives), and then immediately offline the sparse file. This will create a degraded RAID-Z1 pool with two drives worth of capacity and no redundancy.
  2. Copy data to the degraded pool.
  3. Replace the offlined sparse-file with the third disk and resilver.

The number of "devices" that a vdev is created with, is permanent after creation. Therefore, you must have three "disks" at the time of creation. This method gives a way to create a degraded RAID-Z1 pool and later restore the absent redundancy.

This method is not recommended, because while copying and while the 3rd drive is absent, there is no redundancy/parity. But it can work.

Solution 2

Unfortunately, at the moment it is not possible:

It is not possible to add a disk as a column to a RAID-Z, RAID-Z2, or RAID-Z3 vdev. This feature depends on the block pointer rewrite functionality due to be added soon. One can however create a new RAID-Z vdev and add it to the zpool.

RAID-Z1 might work with just 2 drives, but clearly this is not very useful if extra drives cannot be added later. RAID-Z (like RAID 5) becomes more efficient, in terms of usable storage space, the more drives that are used.

Solution 3

RAID-Z1 can be used with only two disks but there is no advantage at all compared to mirroring - unless your two disks have different sector sizes, so that they can't be mirrored (e.g.: a new 4K sector disk and an older 512 byte disk).

As already stated, adding a device to a RAID-Z isn't supported. Should you want to add a disk to an existing RAID-Z, the only way is to backup your data elsewhere, destroy the the pool and recreate it with the extra disk added then restore your data.

Solution 4

Don't have enough "reputation" to comment, so putting this in as a separate answer

RE: Holger G suggestion

while I agree that this is NOT safe... I found this thread looking for a way to go from RAIDZ1 to RAIDZ2 at a later date when extra drive can be acquired.

So Holgers suggestion works great for me - create a RAIDZ2 with one dev as sparse file, offline the file device and have effectively RAIDZ1 for a while and then add a real device at some point to double the redundancy

Also works for the situation where the one drive holds the data that is to be copied to the new raid, as the OP has.

Share:
19,491

Related videos on Youtube

Community
Author by

Community

Updated on September 18, 2022

Comments

  • Community
    Community over 1 year

    Let's say I have two 2TB HDDs and I want to start my first ZFS zpool. Is it possible to create a RAIDZ with just those two discs, giving me 2TB of usable storage (if I understand it right) and then later add another 2TB HDD bringing the total to 4TB of usable storage. Am I correct or does there need to be three HDDs to start with?

    The reason I ask is I already have one 2TB drive I'm using that's full of files. I want to transition to a zpool but I'd rather only buy two more 2TB drives if I can. From what I understand, RAIDZ behaves similarly to RAID5 (with some major differences, I know, but in terms of capacity). However, RAID5 requires 3+ drives. I was wondering if RAIDZ has the same requirement.

    If I have to, I can buy the three drives and just start there, later adding the fourth, but if I could start with two and move to three that would save me $80.

  • Icydog
    Icydog about 10 years
    Here we are three years later, and the Wikipedia page still says "due to be added soon" ... :(
  • Mikhail T.
    Mikhail T. over 8 years
    RAIDZ2 are silly -- the only situation, when the configuration might be useful, is a correlated failure of two drives. Instead of using two disks to guard against that, protect yourself against such failures by using same-capacity disks from different manufacturers and/or of different models.
  • jlliagre
    jlliagre about 8 years
    @Icydog real soon now ;-)
  • antiduh
    antiduh almost 7 years
    @MikhailT. - While using different manufacturers is good advice, it is terrible advice to say that RaidZ2 is silly; a rebuild is very likely to kill another drive.
  • Mikhail T.
    Mikhail T. almost 7 years
    rebuild is very likely to kill another drive - only if all drives are identical to the already failed one and thus likely to suffer a correlated failure. And in this case, having two drives will not help you either -- they are likely to all fail at once. If the expected drive-failures are independent, then sacrificing multiple disks to redundancy buys no perceptible improvement in reliability.
  • jsaddwater
    jsaddwater over 5 years
    Thanks for this answer. We're not always looking for the recommended solution. Sometimes we're looking for ANY solution. A link to how to do what you explain would be nice
  • jsaddwater
    jsaddwater over 5 years
    Unfortunately I can't create a 1TB sparse file on a 250GB drive, so when creating a RAIDZ array with 2 1TB drives + one sparse file (10GB) the array becomes 3x10GB. After removing the sparse file I couldn't grow the array because I couldn't copy the data from the third drive to a small array of 3x10GB and the array can't be grown in degraded state. Catch 22.
  • black_puppydog
    black_puppydog over 5 years
    what about now? :)