Solved

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

Posted on 2010-11-23
4
641 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
couldn't find any other way to do it.  Not ideal, but zdb won't hang under degraded configurations.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now