LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-22-2017, 11:41 PM   #1
Grabby
Member
 
Registered: Feb 2016
Posts: 69

Rep: Reputation: Disabled
How to recover data from a Btrfs partition which was partially overwritten by mistake


I have mistakenly used my (btrfs) /home Linux partition for the installation of FreeBSD, and it was overwritten by the UFS filesystem. Now this UFS-formatted and written partition is not even readable by Linux, as it refuses to be mounted, I don't understand why. The error message when trying to mount it is:

Error mounting /dev/sda2 at /media/adfa/59ed656a78c3231b: Command-line `mount -t "ufs" -o "uhelper=udisks2,nodev,nosuid" "/dev/sda2" "/media/adfa/59ed656a78c3231b"' exited with non-zero exit status 32: mount: /dev/sda2 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/sda2,
missing codepage or helper program, or other error


Anyway, most probably I should not even be trying to mount it the normal way, because I don't want to read it as UFS.

What I need to use is a recovery tool which supports btrfs, but I don't know what to use.

I am sure that the partition was only partially overwritten (because it is over 300 GB, and the FreeBSD installation is much smaller), and I wish to recover at least some of the files, even if I have to do it manually (i.e. by searching for specific strings through raw data).

Can you please help me?

Last edited by Grabby; 10-23-2017 at 01:08 AM.
 
Old 10-23-2017, 01:40 AM   #2
Stéphane Ascoët
Member
 
Registered: Feb 2004
Location: Fleury-les-Aubrais, 120 km south of Paris
Distribution: Devuan, Debian, Mandrake, Freeduc (the one I used to work on), Slackware, MacOS X
Posts: 251

Rep: Reputation: 49
Post Recover a destroyed FS

Begin to make a raw copy of it to work on and try recuperation tools like testdisk. The idea would be to force the FS to be seen as BT instead of UDF, perhaps that you'll need to manually edit the first sector??? Good luck...
 
1 members found this post helpful.
Old 10-23-2017, 02:44 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
As suggested, testdisk, and its associated program photorec, is the often recommended way of recovering any still useful files. The website has several pages that are useful, including pointers as to how to scrape data from any recovered files to attempt to give them meaningful names.

You might also spend some time on the btrfs wiki - the restore command would be a good start. I've not tested it personally.

Last edited by syg00; 10-23-2017 at 02:46 AM.
 
Old 10-23-2017, 02:59 AM   #4
Grabby
Member
 
Registered: Feb 2016
Posts: 69

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by syg00 View Post
As suggested, testdisk, and its associated program photorec, is the often recommended way of recovering any still useful files. The website has several pages that are useful, including pointers as to how to scrape data from any recovered files to attempt to give them meaningful names.

You might also spend some time on the btrfs wiki - the restore command would be a good start. I've not tested it personally.
I have not tried testdisk yet, but from what I have read online it only recovers files, and ignores directory structures.
Do you think that any other tool (maybe one of the Windows-based payware tools) may be able to recover both files AND directory structures from a damaged Btrfs partition?
 
Old 10-23-2017, 03:58 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
duplicate of https://www.linuxquestions.org/quest...gs-4175616189/
There is no such thing "raw filesystem".
You need to create a copy of that partition (for example with dd) and you can analyze that copy. I don't really know if you can force to use it as btrfs or ufs, and also be able to find anything. As far as I heard testdisk is a really good tool to recover (files).
https://en.wikipedia.org/wiki/Btrfs here you can find a few words about btrfs-restore, but I have never tried that.
 
1 members found this post helpful.
Old 10-23-2017, 04:24 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Testdisk can only deal with what it has - overwriting the beginning of a "normal" filesystem (say ext4) wipes out the inodes with all the directory/filename info. It is no more.
btrfs is different in structure, but I'd be guessing - as the wiki says, get on irc and talk to people that know.

I trust you have noted my sigline.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
btrfs filesystem df /mnt/btrfs/ shows bothe data and metdata with raid1 and single. gonus Linux - Software 3 07-17-2014 02:48 PM
Need data recovery ideas for overwritten partition Xotli Linux - General 31 07-15-2010 04:47 AM
ext3 used as ext4 by mistake.. Any way to recover my data? Please help. DigiH Linux - Desktop 9 11-27-2009 02:27 AM
recover data from hd partition... aarca Linux - Hardware 1 08-18-2009 03:34 AM
recover partition + data varun_saa Mandriva 15 05-23-2008 08:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration