# zpool disk destroyed. Unable to import



## eskilbrun (Jun 13, 2013)

I was unlucky enough to have one of the disks in my five-disk zpool destroyed by accident. I bought a new blank disk to replace it. But I could not get the zpool replace command to work. Now I cannot import the pool. But I believe that if I can recreate the label on the missing disk I can manage to import and resilver the missing disk. I know the GUID of the missing disk. Here is a script I wrote to emulate the exact situation I have. A zpool with one disk destroyed and knowing the disk GUID:

```
#!/bin/sh 
set -vx

# Just in case zpool trouble was imported, export it.
zpool export trouble

# Directory for disk files
dir=/tmp

# Make 5 disk files with minimum size for a zpool. 64M
for num in $(seq 1 5)
do
   dd if=/dev/zero bs=1048576 count=64 of=$dir/disk$num
done

# Create a zpool with name=trouble
zpool create trouble $dir/disk1 $dir/disk2 $dir/disk3 $dir/disk4 $dir/disk5

# Create a filesystem in the trouble zpool
zfs create trouble/files

# Put a file in the filesystem
echo Trouble arises when a disk is destroyed >/trouble/files/truth.txt

# export trouble zpool
zpool export trouble

# get the guid of the first disk before we destroy it
zdb -l $dir/disk1 | grep -v _guid: | grep guid: | head -1

# Now, destroy the first disk. 
dd if=/dev/zero bs=1048576 count=64 of=$dir/disk1

# This fails. Miserably
zpool import -d $dir trouble
zpool import -d $dir
```

How can I bring my zpool up to a working condition?

Eskil...


----------



## eskilbrun (Jun 13, 2013)

In case this is helpful in understanding how my zpool looked before I lost the zpool.cache file, here it is:


```
root@filer:/root # zpool status
  pool: zpool
 state: UNAVAIL
status: One or more devices could not be opened.  There are insufficient
	replicas for the pool to continue functioning.
action: Attach the missing device and online it using 'zpool online'.
   see: http://illumos.org/msg/ZFS-8000-3C
  scan: none requested
config:

	NAME                    STATE     READ WRITE CKSUM
	zpool                   UNAVAIL      0     0     0
	  gpt/ad10              ONLINE       0     0     0
	  gpt/ad14              ONLINE       0     0     0
	  gpt/ad16              ONLINE       0     0     0
	  17911202060450540261  UNAVAIL      0     0     0  was /dev/gpt/ad6
	  gpt/ad8               ONLINE       0     0     0

root@filer:/root # zpool replace zpool 17911202060450540261 ada4
cannot open 'zpool': pool is unavailable
```

Some people have apparently been able to import the zpool by creating a label with the correct pool and missing disk GUID. But there are no tools available for this so people have used hex editors on the label blocks to achieve this. I have tried to recreate the partition info with gpart but I believe I must also create the ZFS label. Could I just make a one-disk zpool and search for the packed GUID numbers in the beginning and last 512 KB of the disk? Would that work? If so, I could probably manage that on my own quite quick. Otherwise any help would be very much appreciated.


----------



## phoenix (Jun 14, 2013)

eskilbrun said:
			
		

> I was unlucky enough to have one of the disks in my five-disk zpool destroyed by accident. I bought a new blank disk to replace it. But I could not get the zpool replace command to work. Now I cannot import the pool. But I believe that if I can recreate the label on the missing disk I can manage to import and resilver the missing disk. I know the GUID of the missing disk. Here is a script I wrote to emulate the exact situation I have. A zpool with one disk destroyed and knowing the disk GUID:
> 
> How can I bring my zpool up to a working condition?



You can't.  You have a non-redundant pool (aka RAID 0).  Your pool is dead, gone, kaput.  There's nothing you can do about it.  The data on that disk is gone, and there's no way to rebuild the data that was on that disk.

Hope you have backups!

And I hope this is a good lesson on why you need to use mirror vdevs, or one of the raidz vdev types!


----------



## eskilbrun (Jun 14, 2013)

Thank you, Freddie.

Gah! I had a four-disk RAID-Z zpool before migrating to the new five-disk zpool. I know the four-disk zpool was RAID-Z because I suc_c_essfully upgraded it from 512 GB disks to 1 TB disks without any problem. And then my fatal mistake was made when I created the new zpool without noticing that I had accidentally created a non-redundant pool.

I do however have off-site catastrophe recovery disks. But not of all the data. Some data will be lost. I will just have to live with that.

Thank you for the help.


----------

