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

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.
 
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).
 
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?
 
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.
 
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>.
 
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.
 
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.
 
"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:
Code:
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#
:\
 
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:
Code:
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
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.
 
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. ;)
 
Back
Top