# [ZFS] Unable to mirror disk with zpool attach



## enigmatyc (Feb 16, 2010)

Hi,

I recently installed the FreeBSD 8.0 + ZFS,
I followed this howto : http://wiki.freebsd.org/RootOnZFS/GPTZFSBoot

I added a disk after the install and now I am unable to do a zpool mirror,

Here are the output :

```
# uname -srp
FreeBSD 8.0-STABLE amd64

# zpool status
  pool: rpool
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        rpool      ONLINE       0     0     0
          ad6p2     ONLINE       0     0     0

errors: No known data errors

# zpool attach rpool ad6p2 ad4p2
cannot attach ad4p2 to ad6p2: permission denied
```

This is the log, I have in /var/log/messages :

```
Feb 16 23:19:11 cube root: ZFS: vdev failure, zpool=rpool type=vdev.open_failed
Feb 16 23:19:11 cube root: ZFS: vdev failure, zpool=rpool type=vdev.no_replicas
```

I am not able to find any information about this problem,
The outputs of gpart list are excatly the same for ad6 and ad4,

Thanks for your future reply !


----------



## phoenix (Feb 17, 2010)

Why are you adding the same vdev (ad6p2) again?

`# zpool attach rpool ad4p2`


----------



## knarf (Feb 17, 2010)

phoenix said:
			
		

> Why are you adding the same vdev (ad6p2) again?
> 
> `# zpool attach rpool ad4p2`



Maybe because the man page says to do so:

`# zpool attach [-f] pool device new_device`

The device parameter is mandatory because a zpool can consist of more than one mirror (imagine something like RAID10).

I was able to use a mirror for my boot-zpool called zroot, but I think I've created the mirror during the install process.


```
pool: zroot
 state: ONLINE
 scrub: none requested
config:

        NAME           STATE     READ WRITE CKSUM
        zroot          ONLINE       0     0     0
          mirror       ONLINE       0     0     0
            gpt/disk0  ONLINE       0     0     0
            gpt/disk1  ONLINE       0     0     0

errors: No known data errors
```

Be very careful when adding disks: "Non-redundant and raidz devices cannot be removed from a pool."

Maybe he gets the permission denied because the slice is still in use?


----------



## phoenix (Feb 17, 2010)

Ah, things have changed, I think.  Way back when I started with ZFS, "zpool add" and "zpool attach" worked in roughly the same way:  add vdevs to the pool.  The different was that "add" created a striped zpool (RAID0 across all vdevs) and "attach" created a mirrored pool (RAID1 across all vdevs).  Thus "zpool create pool disk1" created a non-redundant pool with a single non-redundant vdev, and "zpool attach pool disk2" would create a mirror pool made up of two non-redundant vdevs.

Now, it seems, the "attach" action is only used to create/expand mirror vdevs.  "zpool create pool mirror disk1 disk2" creates a pool with a single 2-way mirror vdev.  "zpool attach pool disk1 disk3" would expand that single 2-way mirror vdev into a single 3-way mirror vdev.


----------



## enigmatyc (Feb 18, 2010)

*[ZFS] Now able to mirror disk with zpool attach*

Hi,

In fact you are right :


> Maybe he gets the permission denied because the slice is still in use?



Like you I used the GPT layout for the disk,
but without labeling the partition,
So the partitions didn't appears in /dev/gpt,
that's why I used the /dev/adxxx instead of /dev/gpt/<label>

To solve my problem, I added a label to each volume with gpart,
then I was able to do :

```
# zpool attach rpool ad6p2 /dev/gtp/disk0
```
Then after the resilvering :

```
# zpool detach rpool ad6p2
```
And at the end :

```
# zpool attach rpool gpt/disk0 /dev/gpt/disk1
```

It seem's that the geom_gpt had the handler on the partition,

I will try to notify the owner of the documentation http://wiki.freebsd.org/RootOnZFS/GPTZFSBoot, to correct/inform about this potential problem,

Thanks for your help !

Regards,


----------



## HarryE (Sep 22, 2010)

*Permission denied-solved*

I also encountered the "permission denied" error when trying to add a second disk to a zpool mirror.

The "new" (ad4) disk had a partition on it, so i did a
[cmd=]dd if=/dev/zero of=/dev/ad4 bs=512 count=1000[/cmd]
on it.

After this, the ad4s1 was gone and I could add the disk to the mirror.
HTH


----------

