On 10/07/2011 11:02 AM, James Lee wrote:
> Hello,
>
> I had a pool made from a single LUN, which I'll call c4t0d0 for the
> purposes of this email. We replaced it with another LUN, c4t1d0, to
> grow the pool size. Now c4t1d0 is hosed and I'd like to see about
> recovering whatever data we can from the original LUN, c4t0d0.
>
> I can still see the ZFS labels on t0 with zdb [1], but it is not
> available for importing (even with zpool import -D). Are there any
> tools available for me to tweak the metadata on the old LUN so that I
> can import it? Is there anything else I can try?
>
> I am using Solaris 10 U9, and before anyone says anything, our SAN guys
> don't really understand ZFS or else I would have made the pool redundant
> in the first place.
I found an old post by Jeff Bonwick with some code that does EXACTLY
what I was looking for [1]. I had to update the 'label_write' function
to support the newer ZFS interfaces:
> /*
> * Write a label block with a ZBT checksum.
> */
> static void
> label_write(int fd, uint64_t offset, uint64_t size, void *buf)
> {
> zio_eck_t *zbt, zbt_orig;
> zio_cksum_t zc;
>
> zbt = (zio_eck_t *)((char *)buf + size) - 1;
> zbt_orig = *zbt;
>
> ZIO_SET_CHECKSUM(&zbt->zec_cksum, offset, 0, 0, 0);
>
> zio_checksum_SHA256(buf, size, &zc);
> zbt->zec_cksum = zc;
>
> VERIFY(pwrite64(fd, buf, size, offset) == size);
>
> *zbt = zbt_orig;
> }
Then I compiled it against the illumos headers...something like:
> /usr/sfw/bin/gcc -I illumos-gate/usr/src/uts/common/fs/zfs -o labelfix
> labelfix.c illumos-gate/usr/src/uts/common/fs/zfs/sha256.c assfail.o -lzfs
> -lnvpair -lmd
And finally ran the resulting binary against the old LUN:
> # zpool import
> # ./labelfix /dev/rdsk/c4t60000970000192602845533030373032d0s0
> # zpool import
> pool: idmtestdb2
> id: 10473782060848894552
> state: DEGRADED
> action: The pool can be imported despite missing or damaged devices. The
> fault tolerance of the pool may be compromised if imported.
> config:
>
> idmtestdb2 DEGRADED
> replacing-0 DEGRADED
> c4t60000970000192602845533030373032d0 ONLINE
> c4t60000970000192602845533030363743d0 UNAVAIL cannot open
> # zpool import idmtestdb2
> # zpool detach idmtestdb2 18335497050081682816
> # zpool status idmtestdb2
> pool: idmtestdb2
> state: ONLINE
> scrub: none requested
> config:
>
> NAME STATE READ WRITE CKSUM
> idmtestdb2 ONLINE 0 0 0
> c4t60000970000192602845533030373032d0 ONLINE 0 0 0
>
> errors: No known data errors
Thank you Jeff!
[1]
http://thread.gmane.org/gmane.os.solaris.opensolaris.zfs/15796/focus=15929
_______________________________________________
zfs-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss