Installed current on top of FAT32 flash, Recover old filesystem??

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Installed current on top of FAT32 flash, Recover old filesystem??

Chris Bennett-4
I very carefully and surely tested which flash drive to use and then
pulled out the wrong one.
I stopped the install with halt and done nothing else.
Should I have yanked it, halted it or just said goodbye?

ddrescue or something else or nothing else?

Thanks, I hope,
Chris Bennett


Reply | Threaded
Open this post in threaded view
|

Re: Installed current on top of FAT32 flash, Recover old filesystem??

Bryan Linton
On 2018-07-14 12:16:53, Chris Bennett <[hidden email]> wrote:
> I very carefully and surely tested which flash drive to use and then
> pulled out the wrong one.
> I stopped the install with halt and done nothing else.
> Should I have yanked it, halted it or just said goodbye?
>

Ouch...  Sooner or later, I think most all people will do
something that will cause loss of data, so don't feel too bad.
The good news is that it usually only happens once, because most
people will find an event like this to be a very strong motivator
to implement additional backup strategies.  It certainly was for
me...

Ordinarily, yanking it would've been the best thing to do, since
halting the system would've flushed more data to the disk that
wouldn't have been written if it had just been yanked, but IIRC
the OpenBSD install program mounts disks synchronously so I don't
think it would've made much difference in this case.

I remember reading a guide about this long ago on the net, and the
first suggested step of data recovery was,

        1. PANIC!

The reason being that it's better to take a step away from one's
computer and do the panicking AWAY from the computer so as not to
exacerbate the situation and cause even more data loss by doing
something hasty.

Once that's done, I can only offer some general advice.

The good news is that the OpenBSD installation is only about 300
MB.  If it was a network install then you may have to double that
(~300 MB to hold the tarballs, ~300 MB to hold the installation).
That means that you very likely have only lost less than a
gigabyte of data.  Depending on how big and how full the flash
drive was, that may leave a significant amount of space that will
still be intact.

The writing of alternative superblocks in the newfs stage would've
probably poked lots of little holes in the data all over the disk.
If you stored large files on the disk, it's likely that they may
have small bits of them that were overwritten.

On the other hand, if you had many small files, it's more likely
that the majority of them will still be intact.

> ddrescue or something else or nothing else?
>

From what I can tell, ddrescue is meant more to recover data from
a failing disk; not one that has been overwritten.

But first things first, make a COPY of your drive with dd RIGHT
NOW!  Anything you do to try to recover anything should be done on
the copy, not the drive itself.

Once that's done, something like sysutils/testdisk is probably
more in line with what you're looking for.

% cat ports/sysutils/testdisk/pkg/DESCR
TestDisk is a powerful free data recovery software! It was
primarily designed to help recover lost partitions and/or make
non-booting disks bootable again when these symptoms are caused by
faulty software, certain types of viruses or human error (such as
accidentally deleting a Partition Table). Partition table recovery
using TestDisk is really easy.

PhotoRec is a file data recovery software designed to recover lost
files including video, documents and archives from Hard Disks and
CDRom and lost pictures (thus, its 'Photo Recovery' name) from
digital camera memory. PhotoRec ignores the filesystem and goes
after the underlying data, so it will still work even if your
media's filesystem has been severely damaged or re-formatted.
%

So it looks like PhotoRec is probably the one you want.

If you need to find your old disklabel (so you know what the
bounds of the disk were) you can try looking in /var/backups.

There should be several "disklabel.*.{backup,current}" files in
there that may contain the disklabel for the drive.  Though I
think those are only created as part of the /etc/daily script run
by cron, so the disk would've had to have been plugged into the
computer when it was run.

If you use multiple disks that would share the same device node
(e.g. /dev/sd3) you could also try looking in /var/mail/root which
would log any changes to those files in the daily insecurity
report.

Other than that, it's almost guaranteed that at least *some* data
was lost.  Depending on the nature of the data, you may be able to
find some scraps of it on your main hard drive too.

Text editors and word processors tend to create backup files, so
looking around for any files that end in ".bak" or a tilde might
provide some results.  Checking vi.recover might also be worthwile
if you were typing anything important in vi.

Once you get through this, I can recommend a few things that may
help to mitigate this in the future:

1) Backup your USB drives to a directory on your hard disk
regularly.  rsync is a good simple tool for this, though
borgbackup is nice too.  Bonus points if you automate it through
hotplug(4).

2) Since manual backups don't tend to get done as often as
necessary, set up an automatic backup system.  rsnapshot is a good
tool for this that runs from cron (it's a thin wrapper around
rsync).  borgbackup is also nice too.  It's less convenient to
access the files since its FUSE support doesn't seem to work on
OpenBSD yet, but it has compression and dedup so it saves a lot
more space than rsync does.


I hope some of this advice is useful, and that you can manage to
salvage what you need from the disk.

If you're successful, please consider updating the list with the
steps you took.

--
Bryan

Reply | Threaded
Open this post in threaded view
|

Re: Installed current on top of FAT32 flash, Recover old filesystem??

Nick Holland
In reply to this post by Chris Bennett-4
On 07/14/18 15:16, Chris Bennett wrote:
> I very carefully and surely tested which flash drive to use and then
> pulled out the wrong one.
> I stopped the install with halt and done nothing else.
> Should I have yanked it, halted it or just said goodbye?
>
> ddrescue or something else or nothing else?

It depends on when you stopped the install.

If you had just done the disk layout, you could probably create (using
OpenBSD) a FAT32 partition that covered the entire disk (where did your
original start?  you might have to recreate some history on an identical
device here to find out) and see if your data is intact.  It very well
could be.

If you completed the install...uh...you have got a problem.  Still,
there are tools around now that will find, with amazing success,
particular types of files on "overwritten" media, though of course
anything that was actually overwritten is not going to be recovered.

Nick.

Reply | Threaded
Open this post in threaded view
|

Re: Installed current on top of FAT32 flash, Recover old filesystem??

STeve Andre'
In reply to this post by Chris Bennett-4


On 07/14/18 15:16, Chris Bennett wrote:

> I very carefully and surely tested which flash drive to use and then
> pulled out the wrong one.
> I stopped the install with halt and done nothing else.
> Should I have yanked it, halted it or just said goodbye?
>
> ddrescue or something else or nothing else?
>
> Thanks, I hope,
> Chris Bennett
>
>
>

https://www.r-studio.com/

This is software I have used in the past to deal with disk disasters.
It's about $80 the last time I used it but it worked pretty well.

Good luck.  If you find some other method, let misc@ know.

--STeve Andre'