Solved

how to query if zpool is online (to get around a bug where zfs commands hang)

Posted on 2010-11-23
4
649 Views
Last Modified: 2013-12-27
I want to simply see if a zpool is online in a script, but need to do it in such a way that gets around a known bug.  Specifically, if I have a pool that is offline, then any call to zfs status, zpool, or zfs commands lock up and create a process which I can not terminate).

I can issue a zdb -c poolname and this enumerates the configuration of the pool, but it does not provide any information whether or not it is online.    

So is there a way to see if a pool is online that doesn't require the zfs or zpool command?  (Or uses the zdb command to enumerate something)?

Note that it is possible that a pool won't have any mounted file systems attached to it, but still perhaps there is a creative way I can use dd or something like that to attempt to read from a raw pool device driver?
0
Comment
Question by:dlethe
  • 3
4 Comments
 
LVL 47

Accepted Solution

by:
dlethe earned 0 total points
ID: 34201509
Found something ...
zdb -uuu poolname  will return I/O error message if pool is offline.  If any expert has a better solution that will run more quickly (I don't mind calling something from C), then I'll be happy to award points.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 37002868
zpool status poolname

  pool: poolname
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        poolname  ONLINE     0     0     0
           mirror-0  ONLINE       0     0     0
            c0t1d0  ONLINE       0     0     0
            c1t1d0  ONLINE       0     0     0

errors: No known data errors
0
 
LVL 47

Author Comment

by:dlethe
ID: 37002923
zpool status can & will hang if a disk goes offline or there is a path failure.  (Mentioned in the original question).  Using zdb is the only way to get around it.  Sorry, I forgot to close the question.
0
 
LVL 47

Author Closing Comment

by:dlethe
ID: 37023119
couldn't find any other way to do it.  Not ideal, but zdb won't hang under degraded configurations.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question