[zfs-discuss] Recover re-created zpool

Andreas Dilger adilger at dilger.ca
Wed Feb 10 17:00:32 EST 2016

On Feb 10, 2016, at 2:39 PM, Hajo Möller via zfs-discuss <zfs-discuss at list.zfsonlinux.org> wrote:
> On 02/10/2016 02:26 PM, Krutskikh Ivan via zfs-discuss wrote:
>> Today my college created a new zpool ontop of existed one with some
>> valuable data.
> Sorry, you pool is lost, "zpool create" is a very destructive command.
> It overwrites the old pools uberblocks with fresh ones, making the old
> pool irrecoverable.

Some things could be done to make this less likely to happen in the future:
- presumably the zpool command will open the disk devices using O_EXCL when
  trying to write new VDEV labels and uberblocks?  This is a Linux mechanism
  to ensure that user tools can be excluded from writing to devices that are
  in use by the kernel.  That helps for the case when running commands on
  disks that are currently in use, but doesn't help for unused disks.
- mke2fs now has a check for isatty(0) and isatty(1) to see if the command is
  run interactively and waits for user to agree when clobbering an existing
  filesystem (using libblkid so that it can detect most filesystem types),
  unless forced or the delay is reduced in the config.  When running non-
  interactively (script), it will print a message and pause for a short time
  to give the operator some time to react and kill the script.
- save a copy of the disk uberblocks to a file (e.g. /var/tmp) so that they
  could be restored after the fact.  There are formats like "qcow2" that
  could make the restoration straight forward, but it could also just be put
  into a new zpool sub-command to restore the uberblock to a disk.
- don't clobber ALL of the uberblocks when formatting a new VDEV.  Clobbering
  three uberblocks would be enough to ensure normal tools would pick the new
  one, but a new zpool command could be added to recover from the remaining
  uberblock in case of such a situation.

Cheers, Andreas

> You may have luck with some advanced forensics, I am not aware of
> anybody having done this.
> Here is an article about recovering deleted files, but as far as I
> understand it requires the uberblocks to be valid and present:
> http://www.joyent.com/blog/zfs-forensics-recovering-files-from-a-destroyed-zpool
> -- 
> Regards,
> Hajo Möller
> _______________________________________________
> zfs-discuss mailing list
> zfs-discuss at list.zfsonlinux.org
> http://list.zfsonlinux.org/cgi-bin/mailman/listinfo/zfs-discuss

Cheers, Andreas

More information about the zfs-discuss mailing list