# How do you reestablish zpool/ZFS arrays after reinstalling the OS?



## palmboy5 (Aug 10, 2010)

If I reinstall FreeBSD for whatever reason on my server, how would I go about adding back my former zpool(s) and ZFS-formatted "partitions"? The furthest I could get when I tried was having zpool say those drives were already a member of a pool.


----------



## Terry_Kennedy (Aug 10, 2010)

palmboy5 said:
			
		

> If I reinstall FreeBSD for whatever reason on my server, how would I go about adding back my former zpool(s) and ZFS-formatted "partitions"? The furthest I could get when I tried was having zpool say those drives were already a member of a pool.


I haven't had that exact situation, but I booted with a different kernel (kernel.old) once and the pool wasn't attached, as the cache was loaded as one of the kernel modules and was unloaded when I switched kernels. I did a `# zpool import -c /boot/zfs/zfs.cache ...` to get it to re-appear. I expect that some flavor of `# zpool import` will work for you. (Note that this cache file is not the same as the ZFS cache device).


----------



## palmboy5 (Aug 10, 2010)

Thanks for your reply. Does that file (zpool.cache for me) become outdated over time? Assuming no hardware changes, can I back up that file now and restore it months later safely?


----------



## Terry_Kennedy (Aug 10, 2010)

palmboy5 said:
			
		

> Thanks for your reply. Does that file (zpool.cache for me) become outdated over time? Assuming no hardware changes, can I back up that file now and restore it months later safely?


I don't know. Perhaps someone with more knowledge of ZFS can chime in. The file's timestamp does get updated on each boot. I _think_ that it is just a shortcut for the system to "remember" the ZFS setup between boots - I'm pretty sure that each disk / partition / whatever that is part of a ZFS zpool has complete knowledge of the entire pool's configuration.


----------



## phoenix (Aug 10, 2010)

With all of the drives in the system, just run *zpool import*.  That will scan all the drives for ZFS metadata, and will show any pools that can be imported.  Then you just import the one you want via *zpool import <poolname>*.


----------



## palmboy5 (Aug 12, 2010)

Once I find a spare IDE HDD (my SATA are all used up) I'll install another copy of FreeBSD and try these out, but until then...

I notice that you're supposed to do *zpool export* beforehand, how necessary is that? This is in the case that the OS dies and I didn't do export.


----------



## phoenix (Aug 12, 2010)

If you don't do an export, an import will fail with the error "pool is in use on another system".  However, you can force the import (*zpool import -f*) if needed.

It's better to do an export beforehand as it cleans up some of the metadata.  But it's not a hard requirement.


----------



## palmboy5 (Aug 13, 2010)

"pool is in use on another system"! That's it! I couldn't remember what it said back when I tried *zpool import* without exporting first. Unfortunately, -f has never worked for me. Example:

```
brisbane-1# zpool create tank raidz label/wd2tb1 label/wd2tb2 label/wd2tb3 label/wd2tb4
invalid vdev specification
use '-f' to override the following errors:
raidz contains devices of different sizes
brisbane-1# zpool create tank raidz label/wd2tb1 label/wd2tb2 label/wd2tb3 label/wd2tb4 -f
cannot open '-f': no such GEOM provider
must be a full path or shorthand device name
brisbane-1# zpool create tank -f raidz label/wd2tb1 label/wd2tb2 label/wd2tb3 label/wd2tb4
cannot open '-f': no such GEOM provider
must be a full path or shorthand device name
brisbane-1#
```
:\


----------



## Terry_Kennedy (Aug 13, 2010)

palmboy5 said:
			
		

> "pool is in use on another system"! That's it! I couldn't remember what it said back when I tried *zpool import* without exporting first. Unfortunately, -f has never worked for me. Example:
> 
> ```
> brisbane-1# zpool create tank raidz label/wd2tb1 label/wd2tb2 label/wd2tb3 label/wd2tb4 -f
> ...


The zpool command arguments are position sensitive. The -f has to come between the ZFS action and the target pool / device(s). For example:
`# zpool create -f tank raidz label/wd2tb1 label/wd2tb2 label/wd2tb3 label/wd2tb4`
Refer to the manpage for more details.


----------



## phoenix (Aug 13, 2010)

Why are you using *create*?  You should be doing *zpool import -f <poolname>* nothing more.  The pool already exists.


----------



## Terry_Kennedy (Aug 13, 2010)

phoenix said:
			
		

> Why are you using *create*?  You should be doing *zpool import -f <poolname>* nothing more.  The pool already exists.


I _hope_ the OP was using it as an example of -f not working.


----------



## palmboy5 (Aug 14, 2010)

Yes, it is an old example back when I first asked about how to get -f to work, at another forum.

Thanks for the clarifications guys. I still need to do a test OS install onto another HDD to see if these commands really work out, but I bet they will.


----------

