From: Duncan <1i5t5.duncan@cox.net>
To: linux-btrfs@vger.kernel.org
Subject: Re: btrfs recovery
Date: Tue, 31 Jan 2017 04:30:41 +0000 (UTC) [thread overview]
Message-ID: <pan$99dce$133426d5$ab6dac5$a744519@cox.net> (raw)
In-Reply-To: 5742ef43-0400-e0c9-c0b7-c8d3c8299f9f@aei.mpg.de
Michael Born posted on Mon, 30 Jan 2017 22:07:00 +0100 as excerpted:
> Am 30.01.2017 um 21:51 schrieb Chris Murphy:
>> On Mon, Jan 30, 2017 at 1:02 PM, Michael Born <Michael.Born@aei.mpg.de>
>> wrote:
>>> Hi btrfs experts.
>>>
>>> Hereby I apply for the stupidity of the month award.
>>
>> There's still another day :-D
>>
>>
>>> Before switching from Suse 13.2 to 42.2, I copied my / partition with
>>> dd to an image file - while the system was online/running.
>>> Now, I can't mount the image.
>>
>> That won't ever work for any file system. It must be unmounted.
>
> I could mount and copy the data out of my /home image.dd (encrypted
> xfs). That was also online while dd-ing it.
There's another angle with btrfs that makes block device image copies
such as that a big problem, even if the dd was done with the filesystem
unmounted. This hasn't yet been mentioned in this thread, that I've
seen, anyway.
* Btrfs takes the filesystem UUID, universally unique ID, at face value,
considering it *UNIQUE* and actually identifying the various components
of a possibly multi-device filesystem by the UUID. Again, this is
because btrfs, unlike normal filesystems, can be composed of multiple
devices, so btrfs needs a way to detect what devices form parts of what
filesystems, and it does this by tracking the UUID and considering
anything with that UUID (which is supposed to be unique to that
filesystem, remember, it actually _says_ "unique" in the label, after
all) to be part of that filesystem.
Now you dd the block device somewhere else, making another copy, and
btrfs suddenly has more devices that have UUIDs saying they belong to
this filesystem than it should!
That has actually triggered corruption in some cases, because btrfs gets
mixed up and writes changes to the wrong device, because after all, it
*HAS* to be part of the same filesystem, because it has the same
universally *unique* ID.
Only the supposedly "unique" ID isn't so "unique" any more, because
someone copied the block device, and now there's two copies of the
filesystem claiming to be the same one! "Unique" is no longer "unique"
and it has created the all too predictable problems as a result.
There are ways to work around the problem. Basically, don't let btrfs
see both copies at the same time, and *definitely* don't let it see both
copies when one is mounted or an attempt is being made to mount it.
(Btrfs "sees" a new device when btrfs device scan is run. Unfortunately
for this case, udev tends to run btrfs device scan automatically whenever
it detects a new device that seems to have btrfs on it. So it can be
rather difficult to keep btrfs from seeing it, because udev tends to
monitor for new devices and see it right away, and tell btrfs about it
when it does. But it's possible to avoid damage if you're careful to
only dd the unmounted filesystem device(s) and to safely hide one copy
before attempting to mount the other.)
Of course that wasn't the case here. With the dd of a live-mounted btrfs
device, it's quite possible that btrfs detected and started writing to
the dd-destination device instead of the original at some point, screwing
things up even more than they would have been for a normal filesystem
live-mounted dd.
In turn, it's quite possible that's why the old xfs /home still mounted,
but the btrfs / didn't, because the xfs, while potentially damaged a bit,
didn't suffer the abuse of writes to the wrong device that btrfs may well
have suffered, due to the non-uniqueness of the supposedly universally
unique IDs and the very confused btrfs that may well have caused.
--
Duncan - List replies preferred. No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master." Richard Stallman
next prev parent reply other threads:[~2017-01-31 4:30 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-30 20:02 btrfs recovery Michael Born
2017-01-30 20:27 ` Hans van Kranenburg
2017-01-30 20:51 ` Chris Murphy
2017-01-30 21:07 ` Michael Born
2017-01-30 21:16 ` Hans van Kranenburg
2017-01-30 22:24 ` GWB
2017-01-30 22:37 ` Michael Born
2017-01-31 0:29 ` GWB
[not found] ` <CAKuJGC_rstHxszJGXgUv0tho__roN0Ro-Z1myVsa-bghCORE+w@mail.gmail.com>
2017-01-31 21:30 ` btrfs recovery - solved for me Michael Born
2017-01-31 23:21 ` GWB
2017-01-31 9:08 ` btrfs recovery Graham Cobb
2017-01-30 21:20 ` Chris Murphy
2017-01-30 21:35 ` Chris Murphy
2017-01-30 21:40 ` Michael Born
2017-01-31 4:30 ` Duncan [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-01-26 9:18 Oliver Freyermuth
2017-01-26 9:25 ` Hugo Mills
2017-01-26 9:36 ` Oliver Freyermuth
2017-01-26 10:00 ` Hugo Mills
2017-01-26 11:01 ` Oliver Freyermuth
2017-01-27 11:01 ` Oliver Freyermuth
2017-01-27 12:58 ` Austin S. Hemmelgarn
2017-01-28 5:00 ` Duncan
2017-01-28 12:37 ` Janos Toth F.
2017-01-28 16:51 ` Oliver Freyermuth
2017-01-28 16:46 ` Oliver Freyermuth
2017-01-31 4:58 ` Duncan
2017-01-31 12:45 ` Austin S. Hemmelgarn
2017-02-01 4:36 ` Duncan
2017-01-30 12:41 ` Austin S. Hemmelgarn
2017-01-28 21:04 ` Oliver Freyermuth
2017-01-28 22:27 ` Hans van Kranenburg
2017-01-29 2:02 ` Oliver Freyermuth
2017-01-29 16:44 ` Hans van Kranenburg
2017-01-29 19:09 ` Oliver Freyermuth
2017-01-29 19:28 ` Hans van Kranenburg
2017-01-29 19:52 ` Oliver Freyermuth
2017-01-29 20:13 ` Hans van Kranenburg
2017-01-19 10:06 Sebastian Gottschall
2017-01-20 1:08 ` Qu Wenruo
2017-01-20 9:45 ` Sebastian Gottschall
2017-01-23 11:15 ` Sebastian Gottschall
2017-01-24 0:39 ` Qu Wenruo
2017-01-20 8:05 ` Duncan
2017-01-20 9:59 ` Sebastian Gottschall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='pan$99dce$133426d5$ab6dac5$a744519@cox.net' \
--to=1i5t5.duncan@cox.net \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).