[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: changing uuid of mdadm array



Hello,

On Sun, Oct 09, 2022 at 07:15:02PM +0100, Tim Woodall wrote:
> I wanted to change the uuid on a component of a md raid1 array.

The same thing was asked on the linux-raid list last month (though for
RAID-10) and didn't really get an answer:

    https://lore.kernel.org/linux-raid/2341a2a9-b86e-f0e5-784a-05dbd474dec5@thelounge.net/

It went down a rabbit hole of trying to convince the OP to do what
they needed to do in some other way.

I don't think changing the device UUID is possible with any
purpose-built tool but if it is you might want to try
asking about it on linux-raid as it must be a pretty exotic thing to
do. Just prepare to be asked why you want to do it and if there is
some way around it, I guess!

> I found the following worked and didn't delete any data:
> mdadm --create /dev/md1 --level=raid1 --force --raid-devices=1 /dev/sdb3

I know you probably know this, but you didn't say, so for everyone
else:

**********************************************************************

This is extremely dangerous so don't do this unless you have backups
and know exactly what you are doing!

**********************************************************************

While you CAN re-create an MD RAID array like this and not destroy
existing data, you at minimum have to use exactly the same options
to re-create it as you did when you created it. That may sound
simple, but there are many options that are set as defaults and
THOSE DEFAULTS HAVE CHANGED OVER TIME, so this gets harder to get
right the older the array is.

Also, you did not specify --assume-clean, which makes sense because
it isn't relevant to RAID-1, but if someone used that --create
command for any RAID level with stripes or parity, md would
immediately sync over the array and destroy the existing data!

When doing something like this as a rescue attempt it is normally
advised to do it with dm-overlay devices so that changes are
temporarily stored on a small amount of scratch space. This allows
you to assemble the RAID and do basic checks like a mount and fsck
and any destructive writes only hit the temporary storage. If
there's a filesystem on there you'll fail pretty quickly when
mounting and doing a fsck, if the create command is wrong. Once you
know you have a working "mdadm --create" command you can stop the
array and repeat with the real devices.

A warning to never use "--create" on an existing array is on the
front page of the Linux RAID wiki:

    https://raid.wiki.kernel.org/index.php/Linux_Raid#When_Things_Go_Wrogn [sic]

> but I couldn't find any way to change the uuid in the member without
> creating the array like this.

I don't think there is a way without either using --create as you
did or stopping the array and hand editing the metadata of the
device in question.

Cheers,
Andy

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


Reply to: