linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Austin S. Hemmelgarn" <ahferroin7@gmail.com>
To: Sylvain Joyeux <sylvain.joyeux@m4x.org>, linux-btrfs@vger.kernel.org
Subject: Re: Replace a corrupted block using a known-good file from another filesystem ?
Date: Tue, 5 Jan 2016 07:37:37 -0500	[thread overview]
Message-ID: <568BB911.4010803@gmail.com> (raw)
In-Reply-To: <CAFENT7KXjVBa0n16=FuWhK6xvgFZ7N5GdH_dVufaZbsx9wmeNA@mail.gmail.com>

On 2016-01-05 07:25, Sylvain Joyeux wrote:
> In the course of the few btrfs crashes I had on my USB backup drive
> (NOT the drive from my other bug report, which is an internal SATA
> drive) - in the last 6 months or so - I ended up having a 4 to 5 bad
> checksums reported by scrub.
>
> This drive is used to synchronize snapshots from my main machine, and
> the corrupted files are system files that are still present on the
> main machine.
>
> I could obviously reset the filesystem on the USB drive, but since the
> goal is to keep a backup history (which the main machine does not
> keep), I would rather avoid that.
>
> Would there be a way to replace the bad blocks using the good file on
> the main filesystem ? Replacing it in each snapshot separately does
> not look very appealing as the file is present on most of them.
Short of manually modifying the underlying block device directly, there 
really isn't much you can do.  However, if the file is in the same place 
in every snapshot, it should be really easy to script from the command 
line with a simple for loop.  Assuming that the file is /bin/bash, the 
following should work if run from the directory containing the snapshots 
(assuming of course that the snapshots are read-only, if not you can 
just remove both of the btrfs property set lines):

for snapshot in * ; do
     btrfs property set ${snapshot} ro false
     cp /bin/bash ${snapshot}/bin/bash
     btrfs property set ${snapshot} ro true
done

You can of course replace /bin/bash in that with any file.

      reply	other threads:[~2016-01-05 12:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 12:25 Replace a corrupted block using a known-good file from another filesystem ? Sylvain Joyeux
2016-01-05 12:37 ` Austin S. Hemmelgarn [this message]

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=568BB911.4010803@gmail.com \
    --to=ahferroin7@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sylvain.joyeux@m4x.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).