linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* MDRaid Rollback
@ 2021-03-24 11:04 Shaun Glass
  2021-03-24 14:34 ` Reindl Harald
  2021-03-24 14:44 ` Andy Smith
  0 siblings, 2 replies; 5+ messages in thread
From: Shaun Glass @ 2021-03-24 11:04 UTC (permalink / raw)
  To: linux-raid

Good Day,

Would just like to know if it is possible at all to break a mirror and
convert a md device back to its original state without losing data ?

Regards

Shaun

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MDRaid Rollback
  2021-03-24 11:04 MDRaid Rollback Shaun Glass
@ 2021-03-24 14:34 ` Reindl Harald
  2021-03-24 14:44 ` Andy Smith
  1 sibling, 0 replies; 5+ messages in thread
From: Reindl Harald @ 2021-03-24 14:34 UTC (permalink / raw)
  To: Shaun Glass, linux-raid



Am 24.03.21 um 12:04 schrieb Shaun Glass:
> Would just like to know if it is possible at all to break a mirror and
> convert a md device back to its original state without losing data?

i don't undertsand what exactly are you trying to do

"break a mirror" - how?
"convert a md device back to its original state" - what?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MDRaid Rollback
  2021-03-24 11:04 MDRaid Rollback Shaun Glass
  2021-03-24 14:34 ` Reindl Harald
@ 2021-03-24 14:44 ` Andy Smith
  2021-03-24 15:13   ` Roman Mamedov
  2021-03-24 21:50   ` Wols Lists
  1 sibling, 2 replies; 5+ messages in thread
From: Andy Smith @ 2021-03-24 14:44 UTC (permalink / raw)
  To: linux-raid

Hello,

On Wed, Mar 24, 2021 at 01:04:07PM +0200, Shaun Glass wrote:
> Would just like to know if it is possible at all to break a mirror and
> convert a md device back to its original state without losing data ?

The default metadata version (1.2) is placed at the start of an
array, so even if zeroed this will prevent the array member being
used as the filesystem that is on top of it.

If you have metadata version 0,9 or 1.0 which are at the end then I
don't see why it wouldn't work. I've never done it though so try it
out first on loop devices.

Don't forget to "mdadm --zero-superblock /dev/sda1" (or whatever
devices) for the member device that you have failed out of the
array, so it is no longer treated as part of an array,

But, this being a RAID-1 you have at least two devices so wouldn't
it be safer to:

- Fail out one device
- Zero that device
- Create new filesystem on the removed device
- Copy data onto it from the still-running array that is currently
  degraded
- Use new filesystem for whatever you wanted

?

Depending on what you are trying to achieve you could also import
the broken our device as ANOTHER MD RAID-1 array so both arrays are
running degraded (and now divergent).

Finally, if you are on superblock versions 1.1 or 1.2 you may be
able to work out the offset into the device and use a loop device to
skip that, so treating it as a normal filesystem:

    https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#The_version-1_Superblock_Format

Cheers,
Andy

-- 
https://bitfolk.com/ -- No-nonsense VPS hosting

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MDRaid Rollback
  2021-03-24 14:44 ` Andy Smith
@ 2021-03-24 15:13   ` Roman Mamedov
  2021-03-24 21:50   ` Wols Lists
  1 sibling, 0 replies; 5+ messages in thread
From: Roman Mamedov @ 2021-03-24 15:13 UTC (permalink / raw)
  To: Andy Smith; +Cc: linux-raid

On Wed, 24 Mar 2021 14:44:07 +0000
Andy Smith <andy@strugglers.net> wrote:

> The default metadata version (1.2) is placed at the start of an
> array, so even if zeroed this will prevent the array member being
> used as the filesystem that is on top of it.
> ...
> Finally, if you are on superblock versions 1.1 or 1.2 you may be
> able to work out the offset into the device and use a loop device to
> skip that, so treating it as a normal filesystem:
> 
>     https://raid.wiki.kernel.org/index.php/RAID_superblock_formats#The_version-1_Superblock_Format

Also could delete the partition and recreate it with the new starting offset,
matching the offset for actual data. Recently I've migrated a couple of disks
off LVM in this manner.

Or if the entire disk was used as an array member, then create a brand new
partition table on it, with a single partition of the required offset.

sfdisk is helpful for dumping partitions into a text file ("-d"), which can
then be edited and restored to the device with "sfdisk /dev/disk < file".

All of this is likely more complex if you have to use GPT.

-- 
With respect,
Roman

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MDRaid Rollback
  2021-03-24 14:44 ` Andy Smith
  2021-03-24 15:13   ` Roman Mamedov
@ 2021-03-24 21:50   ` Wols Lists
  1 sibling, 0 replies; 5+ messages in thread
From: Wols Lists @ 2021-03-24 21:50 UTC (permalink / raw)
  To: linux-raid

On 24/03/21 14:44, Andy Smith wrote:
> But, this being a RAID-1 you have at least two devices so wouldn't
> it be safer to:
> 
> - Fail out one device
> - Zero that device
> - Create new filesystem on the removed device
> - Copy data onto it from the still-running array that is currently
>   degraded
> - Use new filesystem for whatever you wanted

Better yet just get another drive and copy it across. You can always do
a "dd if=/dev/md0 of=/dev/sdc1" or whatever is appropriate. (And before
anyone asks, I'm planning to copy a filesystem that way, because it's
chokker with hard links. I *really* don't want to cp the contents ...)

BUT. If you really do want to break the mirror (as I might, just to see
what happens :-), then your best bet is to add a third disk, let it
sync, then fail it off and play with that disk.

As the others said, if you have a 0.9 or 1.0 superblock, your filesystem
starts in the same place as your partition, so if you delete the
superblock the partition becomes non-raid. But if your superblock is 1.1
or 1.2, then that won't work.

Cheers,
Wol

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-03-24 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-24 11:04 MDRaid Rollback Shaun Glass
2021-03-24 14:34 ` Reindl Harald
2021-03-24 14:44 ` Andy Smith
2021-03-24 15:13   ` Roman Mamedov
2021-03-24 21:50   ` Wols Lists

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).