How to recover data from a Btrfs partition which was partially overwritten by mistake
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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).
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:
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...
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.
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?
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.