Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Jul 2013 13:46:03 +0200
From:      Stefan Esser <se@freebsd.org>
To:        linnemannr@gmail.com
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Attempting to roll back zfs transactions on a disk to recover a destroyed ZFS filesystem
Message-ID:  <51E28F7B.7090303@freebsd.org>
In-Reply-To: <51DFF79C.905@gmail.com>
References:  <CA%2B0MdpMj81=Ct-ZUJ7N-TYO=OCHeEomU4Xa70sFVVoBoyETzkQ@mail.gmail.com> <51DFF79C.905@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Am 12.07.2013 14:33, schrieb Volodymyr Kostyrko:
> You can try to experiment with zpool hidden flags. Look at this command:
> 
> zpool import -N -o readonly=on -f -R /pool <pool>
> 
> It will try to import pool in readonly mode so no data would be written
> on it. It also doesn't mount anything on import so if any fs is damaged
> you have less chances triggering a coredump. Also zpool import has a
> hidden -T switch that gives you ability to select transaction that you
> want to try to restore. You'll need a list of available transaction though:
> 
> zdb -ul <vdev>
> 
> This one when given a vdev lists all uberblocks with their respective
> transaction ids. You can take the highest one (it's not the last one)
> and try to mount pool with:
> 
> zpool import -N -o readonly=on -f -R /pool -F -T <transaction_id> <pool>

I had good luck with ZFS recovery with the following approach:

1) Use zdb to identify a TXG for which the data structures are intact

2) Select recovery mode by loading the ZFS KLD with "vfs.zfs.recover=1"
   set in /boot/loader.conf

3) Import the pool with the above -T option referring to a suitable TXG
   found with the help zdb.

The zdb commands to use are:

# zdb -AAA -L -t <TXG> -bcdmu <POOL>

(Both -AAA and -L reduce the amount of consistency checking performed.
A pool (at TXG) that needs these options to allow zdb to succeed is
damaged, but may still allow recovery of most or all files. Be sure
to only import that pool R/O, or your data will probably be lost!)

A list of TXGs to try can be retrieved with "zdb -hh <POOL>".

You may need to add "-e" to the list of zdb options, since the port is
exported / not currently mounted).

Regards, STefan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51E28F7B.7090303>