# Replacing a faulty hard drive with/or without destroying the pool



## tab2tab (Jun 4, 2010)

Hi 

I need to replace a faulty drive in a pool.


```
NAME                       STATE     READ WRITE CKSUM
ztuff                      DEGRADED     0     0     0
  raidz1                   DEGRADED     0     0     0
    ad20                   ONLINE       0     0     0
    ad10                   ONLINE       0     0     0
    replacing              DEGRADED     0     0     0
      6593106060832037185  UNAVAIL      0   690     0  was /dev/ad20/old
      ad16                 ONLINE       0     0     0
    ad18                   ONLINE       0     0     0
```

When I try to replace it IO get the following error.


```
NAS# zpool replace -f ztuff 6593106060832037185 ad16
invalid vdev specification
the following errors must be manually repaired:
/dev/ad16 is part of active pool 'ztuff'
```

I found an answer on the internet.



> Part of a ZFS pool
> 
> The disk or file is part of an active ZFS storage pool. To correct this error,
> use the zpool command to destroy the pool.



If I destroy the pool I will loose all the data, right? I'm a bit confused about what to do...

Any help will be most appreciated!

Thanks!


----------



## Alt (Jun 4, 2010)

Seems you wrongly added ad16 to pool.
You must use `zpool replace` without adding ad16 to pool (this command will do it).
Now i dont know how to remove it.. If its a RAIDZ you can't delete drive from it...


----------



## tab2tab (Jun 4, 2010)

I also had to replace the motherboard so I might have screwed up the the ports. But for the other pool that didn't matter... If it will help I could change the ports, but so far I haven't done anything... 

Seems strange that it would be impossible to replace and save the data in the pool...


----------



## Alt (Jun 5, 2010)

Its possible, but there is no way to remove ad16 from pool since its already added. At least afaik


----------



## danbi (Jun 7, 2010)

Good idea is to use glabel on the drives and create the pool using the labels, not the 'raw' devices.
That way, it will not matter where you plug in the drive it will be still properly configured in the pool.

Your safest route is to either make backup of the data in the pool or recreate the pool again. Possibly making use of glabel 
Or if you have spare disks and ports on the motherboard, create a new one with new disks, copy data over, then destroy the old pool.

I guess, it might be possible to use zdb to fix the pool, but I have never done this and would try the other routes first, if possible.


----------

