zfs_recover
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | zfs_recover [2021/02/01 05:55] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Recovering files in ZFS ====== | ||
+ | This happened: I erased some file by accident. I wrote a bit of data later after that by mistake. | ||
+ | |||
+ | You can use klennet ZFS recovery program [1] to scan the ZFS pool of disks and find out if your information is still there. Unfortunately, | ||
+ | |||
+ | Another person [2] mentions a method using a modified zdb and mdb programs to do this. The problem is that mdb is not available for linux, and there are no clear instructions of how to modify it. | ||
+ | |||
+ | The last method is by importing your pool using an older transaction number [3]. zpool manpage mentions that using -T option is " | ||
+ | |||
+ | What I want: | ||
+ | |||
+ | - Recover as much as possible of the deleted files. Find out if the recovered files are corrupted or not (to re-download them from somewhere else). | ||
+ | - Return to the last zfs pool transaction state (where the files are missing) in order to have a consistent zfs filesystem to work with. | ||
+ | |||
+ | |||
+ | This is how I did it: | ||
+ | |||
+ | * Import the pool as readonly | ||
+ | |||
+ | sudo zpool import -o readonly=on -l tardis | ||
+ | |||
+ | * Find the current uberblock transaction number: | ||
+ | |||
+ | sudo zdb tardis | grep "txg = " | ||
+ | |||
+ | * Go to windows. Install Klennet ZFS Recovery program. (you can do this with virtualbox, you will have to create virtual "raw disks" that point to your real disks). | ||
+ | * Create virtual raw disks in linux [5]: | ||
+ | * For your windows usb to go key: | ||
+ | |||
+ | VBoxManage internalcommands createrawvmdk -filename usbkey.vmdk -rawdisk / | ||
+ | |||
+ | * For each of your ZFS disks: | ||
+ | |||
+ | VBoxManage internalcommands createrawvmdk -filename < | ||
+ | |||
+ | * Configure virtualbox to recognize this disks. Configure your windows 10 vmachine to use this disks. | ||
+ | * Configure your windows vmachine to use at least 16GB of RAM. If not, it will crash. | ||
+ | * Start Klennet ZFS recovery software and during scan set: LZ4 compression, | ||
+ | * Proceed to scan. It will take a lot of time (days even) | ||
+ | * At the end you will be able to explore the recognized files. Find out the transaction number that contains your files. Write the number down. | ||
+ | * Save the program state (in case you need to run the program again) | ||
+ | * Save all the file name list. | ||
+ | * Program a script that calculate the files that are missing from your current zfs linux state against the Klennet ZFS cvs file in the transaction of interest. [4] This will tell you exactly what to try to copy. | ||
+ | * Now to the good/ | ||
+ | * import your zpool with the transaction number from windows. | ||
+ | |||
+ | sudo zpool import -T <klennet old txg number> -o readonly=on -l tardis | ||
+ | |||
+ | * Check that you have more files than before in the expected directories. | ||
+ | * Copy those files. While copying be sure to redirect the stdout and stderr to a file to have a report of the files that give "read errors" | ||
+ | * export the zpool | ||
+ | * Import zpool again but without the -T option still readonly. Check that the filecount on the directories of interest is the correct one. | ||
+ | * Export and reimport but without readonly option. All fine now!!! | ||
+ | * Optional: run a md5sum on all your zfs files to be sure everything is back in order. If a file is corrupted you will get a read error. | ||
+ | * Copy back your recovered files to your zfs pool!!! | ||
+ | |||
+ | All done!!! | ||
+ | |||
+ | And now: Really make a real backup. And remember don't disable your backup during a computer/ | ||
+ | |||
+ | |||
+ | [1] [[https:// | ||
+ | |||
+ | [2] [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [3] [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [4] Script for finding out the missing files | ||
+ | |||
+ | [5] [[https:// | ||
+ | |||
+ | [[http:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | [[https:// |
zfs_recover.txt · Last modified: 2021/02/01 05:55 by 127.0.0.1