# Can I attach a zvol to mirror?



## chunlinyao (Aug 25, 2012)

Hi

I have a mirror which have a disk not stable. I don't have disk to replace it now. I created a zvol from other pool. And try to attach the zvol to the mirror. But I got "no such pool or dataset " error message.

The target mirror

```
NAME        STATE     READ WRITE CKSUM
	safe        ONLINE       0     0     0
	  mirror-0  ONLINE       0     0     0
	    ada0p1  ONLINE       0     0     0
	    ada1p1  ONLINE       0     0     0
```


```
zpool attach safe ada0p1 /dev/zvol/data/safedisk
cannot attach /dev/zvol/data/safedisk to ada0p1: no such pool or dataset
```

Does FreeBSD support the use of a zvol as a device for a zpool?


----------



## Sebulon (Aug 25, 2012)

chunlinyao said:
			
		

> zpool attach safe ada0p1 /dev/zvol/data/safedisk
> cannot attach /dev/zvol/data/safedisk to ada0p1: no such pool or dataset



You should be able to that theoretically, but this must be the first time IÂ´ve seen anyone actually trying to do it

Maybe try "fooling" it by GPT partitioning the zvol and use the GPT partition-name (or label-name) when attaching?

/Sebulon


----------



## chunlinyao (Aug 26, 2012)

glabel and geom nop not work.

I can google some blog about opensolaris can create zpool on zvol.
https://blogs.oracle.com/constantin/entry/opensolaris_home_server_zfs_and

But no information about freebsd can or cannot do it.


----------



## Sebulon (Aug 26, 2012)

@chunlinyao

Have you tried to GPT-partition the zvol?

`# gpart create -s gpt /dev/zvol/data/safedisk`
`# gpart add -t freebsd-zfs -l safedisk /dev/zvol/data/safedisk`
`# zpool attach safe ada0p1 gpt/safedisk`

/Sebulon


----------



## chunlinyao (Aug 27, 2012)

Sebulon said:
			
		

> @chunlinyao
> 
> Have you tried to GPT-partition the zvol?
> 
> ...



I tried it. Got same error.

```
nas4free:~# zpool attach safe ada0p1 gpt/safedisk
cannot attach gpt/safedisk to ada0p1: no such pool or dataset
nas4free:~# zpool create test gpt/safedisk
cannot create 'test': no such pool or dataset
```


----------



## Sebulon (Aug 28, 2012)

@ chunlinyao

Rats. What FreeBSD version are you on?
`# uname -a`

Perhaps this is fixed in newer versions? I donÂ´t know, but maybe it would be worth a shot to csup and build a new world, or freebsd-update?

/Sebulon


----------



## chunlinyao (Aug 30, 2012)

Sebulon said:
			
		

> @ chunlinyao
> 
> Rats. What FreeBSD version are you on?
> `# uname -a`
> ...



All posts before this did on nas4free, which is based on freebsd 9.0

Today I installed freebsd-9.1-RC1 in another machine and test the zfs on zvol feature.
Got same error message. I tried with and without gpt.


----------



## chunlinyao (Aug 30, 2012)

Downloaded a opensolaris vbox image.And confirmed it can do zfs on zvol


----------



## bendany (Oct 26, 2012)

I have the same problem. 9.0-RELEASE.

I test it on solaris 11, it works fine.
can attach zvol to rpool as a mirror device.


----------



## bthomson (Oct 7, 2013)

Still not working in 9.1-RELEASE.

A similar thing that does work is to create a zpool from normal files on a ZFS dataset (see this blog). Unfortunately the performance was really bad. I got about 3 MB/s sequential write on a 260 MB/s pool. Mucking about with the checksum and sync parameters may improve performance.


----------



## chunlinyao (Oct 12, 2013)

*[Solved] can I attach a zvol to mirror*

Confirmed working in 9.2-RELEASE and 10.0-ALPHA
Now we can create zpool on zvol.


----------

