Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Btrfs partitions with problem while using, Help! #670

Open
musicomputer-tao opened this issue Jun 20, 2024 · 14 comments
Open

Btrfs partitions with problem while using, Help! #670

musicomputer-tao opened this issue Jun 20, 2024 · 14 comments

Comments

@musicomputer-tao
Copy link

This is a demanding and awesome project, great and useful, I think.
And I've met some problems, after I installed the drivers.

Env:
The hard disk drive, ST3000NM0033(CMR).
Its part table includes two btrfs partitions, Medium_Btrfs(650GB in Linux) and Lagging_Btrfs(568GB in Linux).(No btrfs part is in other disks.)
I've created these in Debian11 with KDE partition tool.(In my mind, but maybe wrong.)
I've used, Windows(11 22631 22000, 10 19045[in most] 17763[not less before], 8.1[sometimes], 7) and Debian(11 and 12, only stable).
(I use zh-cn, Simplified Chinese in system. So maybe some words in files you can't understand.)
Screenshot--All_part_of_ST3000NM0033_20240620_210321

These are problems I've met all about:
(If you like one problem per one issue, I can alt.)

  1. (Medium_Btrfs gone)
    I've used btrfs scrub, last year in Debian11. Then, I restart computer to Windows 10, but Medium_Btrfs isn't able to access anymore. I tried to save it, but failed. Below, there is all archives I can found (I saved before). (Another btrfs part, was without any changed, as normal.)(Driver I've used is WinBtrfs 1.8.2 .)
    (I really never had thought, a part can leave me in a moment.)
    (Run btrfs scrub -- restart computer to Windows 10 -- final)(So I deduce that at most only a small amount of data has been modified. The data of the part should be safe.)

The result of scrub ran: 检查btrfs分区(显式输出)--20231112.txt
Scan the disk with Victoria (Scan for bad track of Disk)(After this event, on 2024-05-11): 扫描ST3000NM0033-结果一个警告-20240511.txt
Ran btrfs check for it: btrfs-20231113.txt
(And one more, information mixes with another, in below.)

  1. (Lagging_Btrfs went been read only.) (In my memory)
    I used uTorrent portable 3.5, downloaded files to Lagging_Btrfs. It has free space.(In my memory, I checked for this several times, in btrfs tab of its attribute.) But it was not able to been writable. I've solved this, by used btrfs check --init-extent-tree. (And it ran in two to three days.)
    (A few free space of the part -- download and download -- suddenly the part went only readable)

  2. (Lagging_Btrfs went not readable.)
    (I've updated WinBtrfs driver version to 1.9 before this.) I installed Windows 8.1 in a VHDX, I wanted to do something awesome. I've found "balance" in btrfs tab of attribute of Lagging_Btrfs. I tried to make it start (balance).(For metadata and system, exclude data.) But, there was something wrong appeard.(Explorer, It lost its response, it should be.) I restated computer, to Windows10, to Debian12, but Lagging_Btrfs was not readable. I've tried all btrfs tools, in documents on Internet I've found. Oh no.(There was a few free space in Lagging_Btrfs. )
    (If I can accept losing balance effect, can I fix it?)
    (Start Balance for the part, start for metadata and system, exclude data, and only a few free space in the part.-- The part became not readable or mountable.)
    There are for files of information for it, most by btrfs tools in Debian 12:
    btrfs check _dev_sda14--Lagging_Btrfs---20240330.txt
    btrfs insp dump-t -b xxx --fllow dev_sda14 --202404.txt
    btrfs-find-root _dev_sda14--Lagging_Btrfs---20240405.txt
    (This is hexdump for RAW data of two btrfs part:) hexdump_btrfs_part-202404.txt

At last, can you help to me fix two parts?
I wonder at least, the directory structure of Medium_Btrfs (Because there is much software in it. Many files of software can be looked for one more time, but how much software I want to know.),
to fix Lagging_Btrfs to readable and writable (Can I use sudo btrfs check --tree-root 366176223232 --repair /dev/sda14 to fix?) .
@maharmstone

If you must help each other. I've made a tip for Readme to stop btrfs driver loading while Windows starting. (To prevent BSOD, if there is Btrfs part failed to mount.) I will pull a request soon.
And, I've translate Readme to Chinese partly before. I'll translate done when I can allocate enough time for it. (I can just use Chinese and English, and I don't have friends in translate group. But I can make a post in digital forum. Have you thought of translate Readme to other languages?)

Thanks for replies.

These things before, are really bad things for me, in my memory. So, I make the issue until today.

@jarrard
Copy link

jarrard commented Jun 30, 2024

Believe it or not. To recover BTRFS you can simple recreate the partition (best done under Linux usbpen) and your files should for the most part be there. There is no need to go through recovery processes which rarely work.

You may still need to scrub and check the recovered partition afterwards however, but yeah, if you loose a btrfs partition, just manually recreate it, should work most times.

@mattw-webcv
Copy link

Hello to Jarrard,

Can you please elaborate on what I'd need to do to simply remake a btrfs partition?
After using win10/btrfson windows; I have a btrfs partition that won't mount in fedora due to bad superblock.
Do I delete the btrfs partition, remake it with any tool, and all my files are there?

@sskras
Copy link

sskras commented Jul 10, 2024

@mattw-webcv, I doubt that deleting + recreating partition somehow would touch the FS state. Recreating the partition is only helpful if the original one is gone.

Have you tried steps from btrfs check --check-data-csum to btrfs rescue zero-log mentioned here:
https://unix.stackexchange.com/questions/369520/btrfs-super-recover-says-all-superblocks-are-good-but-mount-disagrees/610296#610296
?

If not, you should probably present the actual error output from Fedora.

@jarrard
Copy link

jarrard commented Jul 10, 2024

Can you please elaborate on what I'd need to do to simply remake a btrfs partition?

Basically just delete the old one and create a new one of same size in location and it should still be there but it may not fix the FS state as sskras mentioned. I use either gnome-disk-utility or gparted.

@mattw-webcv
Copy link

Hi, I'm sorry but I'm running in a live session and didn't think to take screenshots.
I used mkfs.btrfs to make a partition, and it enabled trim. Now I have a mounted empty btrfs partition.

If I knew how to post this as its' own issue, I'd do that for everyones' convenience.
For now I'm testing gparted and will respond with more later.

Summary:
I narrowed the problem down to bad superblocks-which I repaired but still wouldn't mount due to checksum.
I tried finding out how to repair checksum, but couldn't find how to.

The short story is I didn't realise winbtrfs changed the partition info, making the drive show up as ntfs.
I have had a bunch of computer troubles and wanted to create a temp windows install. All my critical data was on a btrfs partition, so I saw the unused ntfs partition and erased it- revealing a btrfs partition.
But now it wasn't findable by windows, and not mountable by fedora.

gnome disks will let me delete the partition through a format, but I'm not convinced I want that.

@jarrard
Copy link

jarrard commented Jul 10, 2024

I think there is a command to mount a drive via force even with bad superblocks but I forgot how.

@mattw-webcv
Copy link

In order to erase any partition, gparted also wants to format the drive too.
Is this something I want?

I looked for ways to force things to mount, but I couldn't find it.
The other solutions I found online to repair btrfs partitions that wouldn't mount, is to mount them in order to repair them.

@jarrard
Copy link

jarrard commented Jul 10, 2024

well quick formatting shouldn't erase the data but if that is your only choice left then I dunno.

There are also probably partition inspection tools that let you grab the data.

Welcome to the world of BTRFS btw. Isn't it fun!

@mattw-webcv
Copy link

mattw-webcv commented Jul 10, 2024

Thanks...

Empty btrfs partition.
There goes 5 years of research.
Thanks anyway for trying.

@sskras
Copy link

sskras commented Jul 10, 2024

@mattw-webcv commented 2 hours ago:

Hi, I'm sorry but I'm running in a live session and didn't think to take screenshots. I used mkfs.btrfs to make a partition, and it enabled trim. Now I have a mounted empty btrfs partition.

IMO, using mkfs always damages chances of data recovery from corrupt structures. That's the last thing I would do.

Summary: I narrowed the problem down to bad superblocks-which I repaired but still wouldn't mount due to checksum. I tried finding out how to repair checksum, but couldn't find how to.

The short story is I didn't realise winbtrfs changed the partition info, making the drive show up as ntfs. I have had a bunch of computer troubles and wanted to create a temp windows install. All my critical data was on a btrfs partition, so I saw the unused ntfs partition and erased it- revealing a btrfs partition. But now it wasn't findable by windows, and not mountable by fedora.

Thanks for the relevant part. Writing NTFS data into Btrfs partition sounds pretty rude. This could make up a separate issue. Not sure if it's the issue of Winbtrfs itself, maybe it's issue in the Windows kernel / NTFS driver.

@mattw-webcv, would you be able to reproduce that, eg. in a virtual machine? (Given enough time)

@mattw-webcv
Copy link

gparted also uses mkfs.btrfs, so I had no hope.

I think now I've just given up on it. I'd like to try and recover data, but I have no familiarity with how to, and all the solutions haven't been painless and smooth and intuitive for me.

I could 'in theory' reproduce in VM, but the way my system is configured, I run separate drives.
My little crisis was due to a few factors merging together, combined with me being too stressed to think clearly.
But, in my experience windows installations will install their boot partition wherever it pleases.
If I install windows on drive 3 as listed by the windows installer, it'll put whatever it wants on the first or second drive, or both. So if you remove that drive later, windows complains and refuses to boot.
Since I was running into boot errors, I didn't comprehensively check which drive was being used; and started erasing ntfs partitions that were being read by the fedora installer as empty and unused. In this case it turned out to be an overlay for winbtrfs. Now I've lost 5 years worth of academic research and organisation because I didn't have access to either of my main installs. No, haven't had the money or opportunity to create backups. Hence my strict separation of partitions and file systems and frequent replacement of drives.

@lesderid
Copy link
Contributor

@mattw-webcv If it already did a whole-device TRIM and it's an SSD, your data is likely gone. If not, you could try Testdisk to recover data. Good luck!

@sskras
Copy link

sskras commented Jul 11, 2024

(I wanted to fork that into a separate discussion, but since Discussions are not enabled on this repo, I am continuing here)

<offtopic>

@mattw-webcv commented yesterday:

I used mkfs.btrfs to make a partition, and it enabled trim.

... but why TRIM ?! :)

Now I have a mounted empty btrfs partition.

If I knew how to post this as its' own issue, I'd do that for everyones' convenience. For now I'm testing gparted and will respond with more later.
...
Now I've lost 5 years worth of academic research and organisation because I didn't have access to either of my main installs.

Well, at least it's another useful skill in data-recovery that you learned during that incident:

  1. When your data is at risk, take no hurry and triple-think every move in advance (research the underlaying mechanisms). Maybe take weeks to analyze it.

And I think of another one:

  1. Research about the safest cross-platform FS, eg: Recommendations on FS to use cross-platform, before deploying them into the production.

Especially when the README says:

You use this software at your own risk. I take no responsibility for any damage it may do to your filesystem. It ought to be suitable for day-to-day use, but make sure you take backups anyway.

I just used NTFS (with the NTFS-3g driver) in past. But exFAT is probably a good match too:
exFAT vs NTFS on Linux

Especially now that it went into the Linux kernel in 2020, and even right after merging proved to be fast enough:
exFAT File-System Performance On Linux 5.9

Then 3 years later it got even faster:
Plotting crazy fast (2.5 mins/plot) in Linux but can't move files to NTFS drives? The answer is ExFAT formatting.

Only if getting more fragmentation than NTFS and longer file system checks after crashes...

<End of brainstorming />

gparted also uses mkfs.btrfs, so I had no hope.

During the data recovery I discourage the use of GUI tools on Linux. On Windows they might be the only, a traditional way. But on Linux they tend to conceal a lot of important details. That's from my experience..

It requires a lot of effort to create a bulletproof and a fool-proof GUI. So "GUIs are the last measure" to me.

@mattw-webcv, may you at least tell the area of your research for the interested readers, please? :)

@sskras
Copy link

sskras commented Jul 11, 2024

@lesderid commented 2 hours ago:

If it already did a whole-device TRIM and it's an SSD, your data is likely gone. If not, you could try Testdisk to recover data. Good luck!

Good to know TestDisk added the support on Jun 27, 2012: cgsecurity/testdisk@d13df23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants