LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Recover data from FAT partition mistakenly reformatted as ext4 (https://www.linuxquestions.org/questions/linux-newbie-8/recover-data-from-fat-partition-mistakenly-reformatted-as-ext4-4175659057/)

TeeSquare 08-13-2019 06:41 AM

Recover data from FAT partition mistakenly reformatted as ext4
 
I have a Lenovo IP 110 80T70015IH purchased in Nov 2016, with 1TB hard disc which was partitioned as follows:
Primary partitions:
"FreeDOS" 1GB, FAT32- (as originally supplied, remains untouched)
"Windows 7" OS 64GB, NTFS (installed subsequently, and in use)
"Ubuntu 16.04 LTS" 64GB, ext3 (installed subsequently, in regular use)
Extended secondary partitions:
"Linux swap" 8.6GB
**"WinData" 54GB, FAT32 (data files, personal documents, mainly backup from old laptop)**
"HomeTT" 54GB, ext3 (data files and documents in current use)
... Some more partitions filling up the free space, mostly empty, each ~107MB, intended for alternative OS or data groups.
All the above partitioning was achieved using outside help, as my understanding of computer technology is very limited -- I need to be told the exact syntax for using the command line.

**This partition got reformatted by mistake a month ago, into a default ext4 file system under a different name when I inadvertently selected this partition instead of the pen drive, and failed to see the warning messages! It has not been accessed ever since. It is possible that the data is still there intact but remains inaccessible (shown as empty).
If there is a reasonably straightforward procedure for recovering the data in "WinData" and reading the (mostly ".doc", "pdf", "jpg", "htm") files and other stuff in it, I would be grateful for any advice. Please provide the syntax and explanation for any command line work, or recovery software to be installed. If the operation would be too risky for a non-geek I'd rather give up the idea and lose the data, as I don't wish to jeopardise the remaining partitions.
I tried reading the "similar threads" -- many years old, and confusing for me!
Thanks, =TeeSquare=

pan64 08-13-2019 06:48 AM

the usual way is: dd the partition into a file on another partition and use testdisk to try to recover data from that image. You need additional space to save what was found.
It is not risky at all, if you have enough space to do that.

rknichols 08-13-2019 11:12 AM

Quote:

Originally Posted by pan64 (Post 6024634)
the usual way is: dd the partition into a file on another partition and use testdisk to try to recover data from that image. You need additional space to save what was found.
It is not risky at all, if you have enough space to do that.

Indeed, though you'll probably have to resort to photorec rather than testdisk since much of the old filesystem structure has been overwritten.

Actually, it's reasonably safe to use either testdisk or photorec on the original volume without making a copy, since neither one will write anything to that source volume unless specifically instructed to do so. Making other attempts to "patch up" the original filesystem definitely requires a copy, or at least setting up a Copy-on-Write snapshot device to hold the changes while preserving the original.

jamison20000e 08-13-2019 05:28 PM

Put your back up in and restore the data... maybe next time anyway. :(

If you have a CD burner or USB drive, external SSD or whatever, use it. ;)

jamison20000e 08-13-2019 05:30 PM

If it's important to me I make many backups.

TeeSquare 08-13-2019 11:18 PM

Thanks for the inputs. I'm afraid I'm not confident enough to try it on my own -- age and concentration are not on my side -- I'll get help from someone which may take a week or two, and I'll post the results.
I did try some reading up -- the cgsecurity web site warns me "... you can face a big data loss due to it’s improper usage ... can convert the dd utility as a “data destroyer” for you. That’s why it is recommended that beginners should not use this command on a production machine until they get familiarity on this...."
I'm simply not comfortable with computer technology, being a retired mechanical engineer with an admittedly old-fashioned outlook! I use my pc more like a typewriter, and have little interest in operating systems, though I've learnt to live with Ubuntu and Mint over recent years.
Anyway, for my understanding, does the file system type (FAT, ext4, etc.) of the lost and new partitions restrict the recovery? I have plenty of free space in several unused partitions which were formatted in ext3. So it should be possible to 'duplicate' the contents for trial recovery. Should the target partition be formatted as FAT to start with, since my lost data consists of old Windows files?
Thanks again, =TeeSquare=

syg00 08-14-2019 12:30 AM

Quote:

Originally Posted by TeeSquare (Post 6024933)
Anyway, for my understanding, does the file system type (FAT, ext4, etc.) of the lost and new partitions restrict the recovery? I have plenty of free space in several unused partitions which were formatted in ext3. So it should be possible to 'duplicate' the contents for trial recovery. Should the target partition be formatted as FAT to start with, since my lost data consists of old Windows files?
Thanks again, =TeeSquare=

Doesn't matter - photorec reads the partition a sector at a time looking for fingerprints of known file types (all yours should be recognised). It's "just data" so you can save it in an ext filesystem ok. Simplest is for you to create a new directory (folder) and use that as the output. Photorec will create a bunch of directories under that and create files with sequential names - the original filenames will have been lost when the FAT allocation table got overwritten.
Generally safe to test so long as you ensure you point the target to some other filesystem.

rknichols 08-14-2019 08:38 AM

There is nothing particularly dangerous about the dd command itself. It's just that it is often used to do dangerous things. You could use the cp command (or, for that matter, "cat >/dev/whatever") to zero the wrong drive just as easily as with dd. That the cp and cat commands do not get the bad reputation is just because they are not typically used to do that sort of thing.

TeeSquare 08-14-2019 09:30 AM

Thank you pan64, rknichols, and especially syg00 for your inputs and clarifications. I now have some understanding of what happens and how, but will defer the operation till I can get some help to execute it, for reasons already mentioned, mainly being a novice with the command line! Anyway I hope to post a SOLVED response in due course.
The current problem is not too urgent, and there are other distractions demanding my attention, such as getting advice on use of a new laptop, for which I'll post some queries in the general section. =TeeSquare=


All times are GMT -5. The time now is 06:14 PM.