linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Renaming md raid and moving md raid to a different machine.
       [not found] <f237651e-536a-e305-8c1c-475e4c14d906@gmail.com>
@ 2023-03-19 18:58 ` Ram Ramesh
  2023-03-19 19:29   ` Reindl Harald
  2023-03-19 22:51   ` Wol
  0 siblings, 2 replies; 11+ messages in thread
From: Ram Ramesh @ 2023-03-19 18:58 UTC (permalink / raw)
  To: Linux Raid

Hi,

   My primary DVR is old and I need to move it to more recent hardware. 
I have two md raids (a raid1 and another raid6) called /dev/md0 and 
/dev/md1. I plan to have root on the new machine on raid1 and thus I 
like to rename my /dev/md0 to /dev/md1 in the old machine before I move 
it to the new machine. After that I want to move the disks in the most 
recommended way to minimize the chance of loss.

   Since the data is large and usually contains recordings and videos 
that have backup on Hulu/Ultraviolet, I worry less about backup. Still 
it will be big task to repopulate all my data from the source and 
therefore prefer not to do stupid things and loose the data.

  Online search showed me a way to rename using just mdadm.conf and that 
did not work at all. In fact it messed up my raid6 that I had a panic 
for a short time. Luckily, I got everything back working normally. So, I 
am not sure which one of the online instructions to follow to rename my 
/dev/md0 to /dev/md1 before the move. So, I thought best to ask here.

   Also, once I renamed /dev/md0 to /dev/md1, I want to move all 6 disks 
in raid6 to the new machine. What is the correct procedure so that after 
the movement, I will be able to reboot both the old machine without 
raid6 (ie /dev/md1)and the new machine with the moved disks as /dev/md1? 
Ideally, I like to teach my old machine to forget /dev/md1 that I want 
to move and not touch the disks. If I do not do that, I am afraid my 
reboot (of the old machine) will get stuck at some point trying to look 
for the missing disks/md. All online tutorial talks about how to 
assemble on new machine. Does not talk about gracefully removing an md 
from an old machine. I want to know if there is any trick to this other 
than shutting down and pulling all disks and rebooting.

   Old host runs debian bullseye (linux 5.19, mdadm v4.1) and new will 
run debian testing/bookworm (linux 6.1,  mdadm v4.2).  Let me know if 
you need anymore information.

Thanks and Regards
Ramesh


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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-19 18:58 ` Renaming md raid and moving md raid to a different machine Ram Ramesh
@ 2023-03-19 19:29   ` Reindl Harald
  2023-03-19 19:52     ` Ram Ramesh
  2023-03-19 22:51   ` Wol
  1 sibling, 1 reply; 11+ messages in thread
From: Reindl Harald @ 2023-03-19 19:29 UTC (permalink / raw)
  To: Ram Ramesh, Linux Raid



Am 19.03.23 um 19:58 schrieb Ram Ramesh:
>    My primary DVR is old and I need to move it to more recent hardware. 
> I have two md raids (a raid1 and another raid6) called /dev/md0 and 
> /dev/md1. I plan to have root on the new machine on raid1 and thus I 
> like to rename my /dev/md0 to /dev/md1 in the old machine before I move 
> it to the new machine. After that I want to move the disks in the most 
> recommended way to minimize the chance of loss.
> 
>    Since the data is large and usually contains recordings and videos 
> that have backup on Hulu/Ultraviolet, I worry less about backup. Still 
> it will be big task to repopulate all my data from the source and 
> therefore prefer not to do stupid things and loose the data.
> 
>   Online search showed me a way to rename using just mdadm.conf and that 
> did not work at all. In fact it messed up my raid6 that I had a panic 
> for a short time. Luckily, I got everything back working normally. So, I 
> am not sure which one of the online instructions to follow to rename my 
> /dev/md0 to /dev/md1 before the move. So, I thought best to ask here.
> 
>    Also, once I renamed /dev/md0 to /dev/md1, I want to move all 6 disks 
> in raid6 to the new machine. What is the correct procedure so that after 
> the movement, I will be able to reboot both the old machine without 
> raid6 (ie /dev/md1)and the new machine with the moved disks as /dev/md1? 
> Ideally, I like to teach my old machine to forget /dev/md1 that I want 
> to move and not touch the disks. If I do not do that, I am afraid my 
> reboot (of the old machine) will get stuck at some point trying to look 
> for the missing disks/md. All online tutorial talks about how to 
> assemble on new machine. Does not talk about gracefully removing an md 
> from an old machine. I want to know if there is any trick to this other 
> than shutting down and pulling all disks and rebooting.
> 
>    Old host runs debian bullseye (linux 5.19, mdadm v4.1) and new will 
> run debian testing/bookworm (linux 6.1,  mdadm v4.2).  Let me know if 
> you need anymore information.

* create new arrays
* mount both on the new machine (1 disk is enough for RAID1)
* use dd


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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-19 19:29   ` Reindl Harald
@ 2023-03-19 19:52     ` Ram Ramesh
  0 siblings, 0 replies; 11+ messages in thread
From: Ram Ramesh @ 2023-03-19 19:52 UTC (permalink / raw)
  To: Reindl Harald, Linux Raid

On 3/19/23 14:29, Reindl Harald wrote:

> * create new arrays
> * mount both on the new machine (1 disk is enough for RAID1)
> * use dd
> 

Mmmm... I need to move 6 disk RAID6 and not RAID1. For now RAID1 will 
stay with old machine. Also, I am trying to avoid coping 24TB of files 
(if possible) as we are talking about 3 days of copying or resyncing.


Regards
Ramesh


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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-19 18:58 ` Renaming md raid and moving md raid to a different machine Ram Ramesh
  2023-03-19 19:29   ` Reindl Harald
@ 2023-03-19 22:51   ` Wol
  2023-03-19 23:29     ` Ram Ramesh
  1 sibling, 1 reply; 11+ messages in thread
From: Wol @ 2023-03-19 22:51 UTC (permalink / raw)
  To: Ram Ramesh, Linux Raid

On 19/03/2023 18:58, Ram Ramesh wrote:
> Hi,
> 
>    My primary DVR is old and I need to move it to more recent hardware. 
> I have two md raids (a raid1 and another raid6) called /dev/md0 and 
> /dev/md1. I plan to have root on the new machine on raid1 and thus I 
> like to rename my /dev/md0 to /dev/md1 in the old machine before I move 
> it to the new machine. After that I want to move the disks in the most 
> recommended way to minimize the chance of loss.

Do you have an mdadm.conf, or do the arrays auto-assemble without one?
> 
>    Since the data is large and usually contains recordings and videos 
> that have backup on Hulu/Ultraviolet, I worry less about backup. Still 
> it will be big task to repopulate all my data from the source and 
> therefore prefer not to do stupid things and loose the data.
> 
>   Online search showed me a way to rename using just mdadm.conf and that 
> did not work at all. In fact it messed up my raid6 that I had a panic 
> for a short time. Luckily, I got everything back working normally. So, I 
> am not sure which one of the online instructions to follow to rename my 
> /dev/md0 to /dev/md1 before the move. So, I thought best to ask here.

Your raid shouldn't be named md0 (md1) at all. By default they now count 
down from md127 (I think ...)

If you're going to give it a name, give it a name like "root", or 
"data", or "home". But I've found that very tricky post-facto - it's 
best done when the array is first created.
> 
>    Also, once I renamed /dev/md0 to /dev/md1, I want to move all 6 disks 
> in raid6 to the new machine. What is the correct procedure so that after 
> the movement, I will be able to reboot both the old machine without 
> raid6 (ie /dev/md1)and the new machine with the moved disks as /dev/md1? 
> Ideally, I like to teach my old machine to forget /dev/md1 that I want 
> to move and not touch the disks. If I do not do that, I am afraid my 
> reboot (of the old machine) will get stuck at some point trying to look 
> for the missing disks/md. All online tutorial talks about how to 
> assemble on new machine. Does not talk about gracefully removing an md 
> from an old machine. I want to know if there is any trick to this other 
> than shutting down and pulling all disks and rebooting.
> 
>    Old host runs debian bullseye (linux 5.19, mdadm v4.1) and new will 
> run debian testing/bookworm (linux 6.1,  mdadm v4.2).  Let me know if 
> you need anymore information.

Old host, new host ...

Sounds to me like the best way to move the raid would simply be to 
transfer the disks across. The new system should just recognise the 
array. If it doesn't you can just put the disks back in the old system.

What I would NOT do is put the old disks in the new system and then 
build it. Make sure the new system is up and running before you move the 
disks across. (There have been reports of 
installers/updates/stuff-like-that not recognising raids and trashing them.)
> 
> Thanks and Regards
> Ramesh
> 
https://raid.wiki.kernel.org/index.php/Linux_Raid

Dunno where you looked on-line, but this is the best place. Any 
improvements you think of, let me know.

Cheers,
Wol

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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-19 22:51   ` Wol
@ 2023-03-19 23:29     ` Ram Ramesh
  2023-03-20  0:01       ` Wol
  0 siblings, 1 reply; 11+ messages in thread
From: Ram Ramesh @ 2023-03-19 23:29 UTC (permalink / raw)
  To: Wol, Linux Raid

On 3/19/23 17:51, Wol wrote:
> On 19/03/2023 18:58, Ram Ramesh wrote:
>> Hi,
>>
>>    My primary DVR is old and I need to move it to more recent 
>> hardware. I have two md raids (a raid1 and another raid6) called 
>> /dev/md0 and /dev/md1. I plan to have root on the new machine on raid1 
>> and thus I like to rename my /dev/md0 to /dev/md1 in the old machine 
>> before I move it to the new machine. After that I want to move the 
>> disks in the most recommended way to minimize the chance of loss.
> 
> Do you have an mdadm.conf, or do the arrays auto-assemble without one?
I have mdadm.conf and each md is named in that file.

ARRAY /dev/md/1 metadata=1.2 name=zym:md1 
UUID=0e9f76b5:4a89171a:a930bccd:78749144
ARRAY /dev/md2  metadata=1.2 name=zym:2 
UUID=d4e30060:d6395b41:dde52d2e:35ffa6fd

>>
>>    Since the data is large and usually contains recordings and videos 
>> that have backup on Hulu/Ultraviolet, I worry less about backup. Still 
>> it will be big task to repopulate all my data from the source and 
>> therefore prefer not to do stupid things and loose the data.
>>
>>   Online search showed me a way to rename using just mdadm.conf and 
>> that did not work at all. In fact it messed up my raid6 that I had a 
>> panic for a short time. Luckily, I got everything back working 
>> normally. So, I am not sure which one of the online instructions to 
>> follow to rename my /dev/md0 to /dev/md1 before the move. So, I 
>> thought best to ask here.
> 
> Your raid shouldn't be named md0 (md1) at all. By default they now count 
> down from md127 (I think ...)
They are named md0, md1, md2 etc because I created them that way, I 
think. Once created, they are entered into mdadm.conf and they keep 
their name.

I usually image copy system disk from old machine to new machine to 
bootstrap the system. Thus mdadm.conf will go there. That is why I 
cannot have /dev/md0 in the old machine as that name is already taken in 
the new machine. Without image copy, it is difficult to get mythtv 
package to keep its database and recordings in order.
> 
> If you're going to give it a name, give it a name like "root", or 
> "data", or "home". But I've found that very tricky post-facto - it's 
> best done when the array is first created.
>>
>>    Also, once I renamed /dev/md0 to /dev/md1, I want to move all 6 
>> disks in raid6 to the new machine. What is the correct procedure so 
>> that after the movement, I will be able to reboot both the old machine 
>> without raid6 (ie /dev/md1)and the new machine with the moved disks as 
>> /dev/md1? Ideally, I like to teach my old machine to forget /dev/md1 
>> that I want to move and not touch the disks. If I do not do that, I am 
>> afraid my reboot (of the old machine) will get stuck at some point 
>> trying to look for the missing disks/md. All online tutorial talks 
>> about how to assemble on new machine. Does not talk about gracefully 
>> removing an md from an old machine. I want to know if there is any 
>> trick to this other than shutting down and pulling all disks and 
>> rebooting.
>>
>>    Old host runs debian bullseye (linux 5.19, mdadm v4.1) and new will 
>> run debian testing/bookworm (linux 6.1,  mdadm v4.2).  Let me know if 
>> you need anymore information.
> 
> Old host, new host ...
> 
> Sounds to me like the best way to move the raid would simply be to 
> transfer the disks across. The new system should just recognise the 
> array. If it doesn't you can just put the disks back in the old system.
> 
> What I would NOT do is put the old disks in the new system and then 
> build it. Make sure the new system is up and running before you move the 
> disks across. (There have been reports of 
> installers/updates/stuff-like-that not recognising raids and trashing 
> them.)
Ok, I will try this. I am more worried about old host not booting after 
I yank the disks and it does not find them to assemble md that 
mdadm.conf has. I am going to comment out the line for the md (and 
update-initramfs for a good measure) that I plan to transfer. This way, 
I should be safe.
>>
>> Thanks and Regards
>> Ramesh
>>
> https://raid.wiki.kernel.org/index.php/Linux_Raid

I thought I looked there first before searching online. I do not believe 
you have any section for renaming md device after its creation.

I also did not find any instructions on how to not assemble array upon 
reboot and leave the component disks untouched. This will make the 
transfer seamless.
> 
> Dunno where you looked on-line, but this is the best place. Any 
> improvements you think of, let me know.
> 
> Cheers,
> Wol

Thanks for taking interest in my situation. Just helping me to think 
differently itself is great help and I appreciate that help.

Regards
Ramesh


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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-19 23:29     ` Ram Ramesh
@ 2023-03-20  0:01       ` Wol
  2023-03-20  0:34         ` Ram Ramesh
  0 siblings, 1 reply; 11+ messages in thread
From: Wol @ 2023-03-20  0:01 UTC (permalink / raw)
  To: Ram Ramesh, Linux Raid

On 19/03/2023 23:29, Ram Ramesh wrote:
>>>    My primary DVR is old and I need to move it to more recent 
>>> hardware. I have two md raids (a raid1 and another raid6) called 
>>> /dev/md0 and /dev/md1. I plan to have root on the new machine on 
>>> raid1 and thus I like to rename my /dev/md0 to /dev/md1 in the old 
>>> machine before I move it to the new machine. After that I want to 
>>> move the disks in the most recommended way to minimize the chance of 
>>> loss.
>>
>> Do you have an mdadm.conf, or do the arrays auto-assemble without one?
> I have mdadm.conf and each md is named in that file.
> 
> ARRAY /dev/md/1 metadata=1.2 name=zym:md1 
> UUID=0e9f76b5:4a89171a:a930bccd:78749144
> ARRAY /dev/md2  metadata=1.2 name=zym:2 
> UUID=d4e30060:d6395b41:dde52d2e:35ffa6fd

Okay. May I suggest that

(1) try getting rid of mdadm.conf - temporarily - and see if everything 
boots fine.

(2) see if you can hard-rename (as in force an update to the metadata) 
the array to a named array eg something like "zym:data"

If you can do (2), then (1) will boot and the array will come up as 
/dev/md/data.

At which point you will be able to move the disks across and everything 
should "just work".

Note that in the modern world your arrays should not be named md1, md2 
etc, as I said. The default numbers count down from - as I said - I 
think 127, and you're advised not to use numbers. I created my original 
arrays as 0, 1, 2 and promptly found they came back as 127, 126, and 125.

I don't know whether advising you to "not have an mdadm.conf" is a good 
idea, but I've never had one, and storing things like array name in the 
metadata is much better than having it stored in an external file.

And it means you won't have clashing names :-) Actually, if you use 
mdadm.conf to rename the arrays you're moving up to md3 or md4, see if 
they boot fine on the old system, and again you can then just dd your 
system across, then move the raid drives across, and you shouldn't have 
any problems.

Cheers,
Wol

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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-20  0:01       ` Wol
@ 2023-03-20  0:34         ` Ram Ramesh
  2023-03-20  8:00           ` Wols Lists
  2023-03-20  8:35           ` Reindl Harald
  0 siblings, 2 replies; 11+ messages in thread
From: Ram Ramesh @ 2023-03-20  0:34 UTC (permalink / raw)
  To: Wol, Linux Raid

On 3/19/23 19:01, Wol wrote:
> On 19/03/2023 23:29, Ram Ramesh wrote:
>>>>    My primary DVR is old and I need to move it to more recent 
>>>> hardware. I have two md raids (a raid1 and another raid6) called 
>>>> /dev/md0 and /dev/md1. I plan to have root on the new machine on 
>>>> raid1 and thus I like to rename my /dev/md0 to /dev/md1 in the old 
>>>> machine before I move it to the new machine. After that I want to 
>>>> move the disks in the most recommended way to minimize the chance of 
>>>> loss.
>>>
>>> Do you have an mdadm.conf, or do the arrays auto-assemble without one?
>> I have mdadm.conf and each md is named in that file.
>>
>> ARRAY /dev/md/1 metadata=1.2 name=zym:md1 
>> UUID=0e9f76b5:4a89171a:a930bccd:78749144
>> ARRAY /dev/md2  metadata=1.2 name=zym:2 
>> UUID=d4e30060:d6395b41:dde52d2e:35ffa6fd
> 
> Okay. May I suggest that
> 
> (1) try getting rid of mdadm.conf - temporarily - and see if everything 
> boots fine.
> 
> (2) see if you can hard-rename (as in force an update to the metadata) 
> the array to a named array eg something like "zym:data"
> 
> If you can do (2), then (1) will boot and the array will come up as 
> /dev/md/data.
> 
> At which point you will be able to move the disks across and everything 
> should "just work".
> 
> Note that in the modern world your arrays should not be named md1, md2 
> etc, as I said. The default numbers count down from - as I said - I 
> think 127, and you're advised not to use numbers. I created my original 
> arrays as 0, 1, 2 and promptly found they came back as 127, 126, and 125.
> 
> I don't know whether advising you to "not have an mdadm.conf" is a good 
> idea, but I've never had one, and storing things like array name in the 
> metadata is much better than having it stored in an external file.
> 
> And it means you won't have clashing names :-) Actually, if you use 
> mdadm.conf to rename the arrays you're moving up to md3 or md4, see if 
> they boot fine on the old system, and again you can then just dd your 
> system across, then move the raid drives across, and you shouldn't have 
> any problems.
> 
> Cheers,
> Wol

Yes the names must be in the metadata of the md because I populate 
mdadm.conf after every change by actually using the output from mdadm 
--detail -scan. Since that comes up with md0/md1/md2, I assume somehow 
mdadm simply finds them again and again with exact same name.

I do not ever get md127.

Regards
Ramesh


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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-20  0:34         ` Ram Ramesh
@ 2023-03-20  8:00           ` Wols Lists
  2023-03-20 14:53             ` Ram Ramesh
  2023-03-20  8:35           ` Reindl Harald
  1 sibling, 1 reply; 11+ messages in thread
From: Wols Lists @ 2023-03-20  8:00 UTC (permalink / raw)
  To: Ram Ramesh, Linux Raid

On 20/03/2023 00:34, Ram Ramesh wrote:
> On 3/19/23 19:01, Wol wrote:
>> On 19/03/2023 23:29, Ram Ramesh wrote:
>>>>>    My primary DVR is old and I need to move it to more recent 
>>>>> hardware. I have two md raids (a raid1 and another raid6) called 
>>>>> /dev/md0 and /dev/md1. I plan to have root on the new machine on 
>>>>> raid1 and thus I like to rename my /dev/md0 to /dev/md1 in the old 
>>>>> machine before I move it to the new machine. After that I want to 
>>>>> move the disks in the most recommended way to minimize the chance 
>>>>> of loss.
>>>>
>>>> Do you have an mdadm.conf, or do the arrays auto-assemble without one?
>>> I have mdadm.conf and each md is named in that file.
>>>
>>> ARRAY /dev/md/1 metadata=1.2 name=zym:md1 
>>> UUID=0e9f76b5:4a89171a:a930bccd:78749144
>>> ARRAY /dev/md2  metadata=1.2 name=zym:2 
>>> UUID=d4e30060:d6395b41:dde52d2e:35ffa6fd
>>
>> Okay. May I suggest that
>>
>> (1) try getting rid of mdadm.conf - temporarily - and see if 
>> everything boots fine.
>>
>> (2) see if you can hard-rename (as in force an update to the metadata) 
>> the array to a named array eg something like "zym:data"
>>
>> If you can do (2), then (1) will boot and the array will come up as 
>> /dev/md/data.
>>
>> At which point you will be able to move the disks across and 
>> everything should "just work".
>>
>> Note that in the modern world your arrays should not be named md1, md2 
>> etc, as I said. The default numbers count down from - as I said - I 
>> think 127, and you're advised not to use numbers. I created my 
>> original arrays as 0, 1, 2 and promptly found they came back as 127, 
>> 126, and 125.
>>
>> I don't know whether advising you to "not have an mdadm.conf" is a 
>> good idea, but I've never had one, and storing things like array name 
>> in the metadata is much better than having it stored in an external file.
>>
>> And it means you won't have clashing names :-) Actually, if you use 
>> mdadm.conf to rename the arrays you're moving up to md3 or md4, see if 
>> they boot fine on the old system, and again you can then just dd your 
>> system across, then move the raid drives across, and you shouldn't 
>> have any problems.
>>
>> Cheers,
>> Wol
> 
> Yes the names must be in the metadata of the md because I populate 
> mdadm.conf after every change by actually using the output from mdadm 
> --detail -scan. Since that comes up with md0/md1/md2, I assume somehow 
> mdadm simply finds them again and again with exact same name.

Not necessarily. mdadm could (probably is) be reading mdadm.conf, 
building the array using the name in mdadm.conf, and then rebuilding 
mdadm.conf based on the name it got from mdadm.conf.
> 
> I do not ever get md127.
> 
If you boot with no mdadm.conf whatsoever? If that gives you md127, then 
you can rename the arrays on the old system by messing with mdadm.conf.

Also, it's just struck me, you're matching array to name using the UUID. 
So, assuming that's the array UUID (what else could it be) when you dd 
the root filesystem across and boot, that array should NOT be called 
md0, because the UUIDs won't match.

Cheers,
Wol

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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-20  0:34         ` Ram Ramesh
  2023-03-20  8:00           ` Wols Lists
@ 2023-03-20  8:35           ` Reindl Harald
  2023-03-20 22:23             ` Ram Ramesh
  1 sibling, 1 reply; 11+ messages in thread
From: Reindl Harald @ 2023-03-20  8:35 UTC (permalink / raw)
  To: Ram Ramesh, Wol, Linux Raid



Am 20.03.23 um 01:34 schrieb Ram Ramesh:
> Yes the names must be in the metadata of the md because I populate 
> mdadm.conf after every change by actually using the output from mdadm 
> --detail -scan. Since that comes up with md0/md1/md2, I assume somehow 
> mdadm simply finds them again and again with exact same name.
> 
> I do not ever get md127

no - your mdadm.conf is in the initrd because how else should the rootfs 
could live on the array containing mdadm.conf

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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-20  8:00           ` Wols Lists
@ 2023-03-20 14:53             ` Ram Ramesh
  0 siblings, 0 replies; 11+ messages in thread
From: Ram Ramesh @ 2023-03-20 14:53 UTC (permalink / raw)
  To: Wols Lists, Linux Raid

On 3/20/23 03:00, Wols Lists wrote:
> On 20/03/2023 00:34, Ram Ramesh wrote:
>> On 3/19/23 19:01, Wol wrote:
>>> On 19/03/2023 23:29, Ram Ramesh wrote:
>>>>>>    My primary DVR is old and I need to move it to more recent 
>>>>>> hardware. I have two md raids (a raid1 and another raid6) called 
>>>>>> /dev/md0 and /dev/md1. I plan to have root on the new machine on 
>>>>>> raid1 and thus I like to rename my /dev/md0 to /dev/md1 in the old 
>>>>>> machine before I move it to the new machine. After that I want to 
>>>>>> move the disks in the most recommended way to minimize the chance 
>>>>>> of loss.
>>>>>
>>>>> Do you have an mdadm.conf, or do the arrays auto-assemble without one?
>>>> I have mdadm.conf and each md is named in that file.
>>>>
>>>> ARRAY /dev/md/1 metadata=1.2 name=zym:md1 
>>>> UUID=0e9f76b5:4a89171a:a930bccd:78749144
>>>> ARRAY /dev/md2  metadata=1.2 name=zym:2 
>>>> UUID=d4e30060:d6395b41:dde52d2e:35ffa6fd
>>>
>>> Okay. May I suggest that
>>>
>>> (1) try getting rid of mdadm.conf - temporarily - and see if 
>>> everything boots fine.
>>>
>>> (2) see if you can hard-rename (as in force an update to the 
>>> metadata) the array to a named array eg something like "zym:data"
>>>
>>> If you can do (2), then (1) will boot and the array will come up as 
>>> /dev/md/data.
>>>
>>> At which point you will be able to move the disks across and 
>>> everything should "just work".
>>>
>>> Note that in the modern world your arrays should not be named md1, 
>>> md2 etc, as I said. The default numbers count down from - as I said - 
>>> I think 127, and you're advised not to use numbers. I created my 
>>> original arrays as 0, 1, 2 and promptly found they came back as 127, 
>>> 126, and 125.
>>>
>>> I don't know whether advising you to "not have an mdadm.conf" is a 
>>> good idea, but I've never had one, and storing things like array name 
>>> in the metadata is much better than having it stored in an external 
>>> file.
>>>
>>> And it means you won't have clashing names :-) Actually, if you use 
>>> mdadm.conf to rename the arrays you're moving up to md3 or md4, see 
>>> if they boot fine on the old system, and again you can then just dd 
>>> your system across, then move the raid drives across, and you 
>>> shouldn't have any problems.
>>>
>>> Cheers,
>>> Wol
>>
>> Yes the names must be in the metadata of the md because I populate 
>> mdadm.conf after every change by actually using the output from mdadm 
>> --detail -scan. Since that comes up with md0/md1/md2, I assume somehow 
>> mdadm simply finds them again and again with exact same name.
> 
> Not necessarily. mdadm could (probably is) be reading mdadm.conf, 
> building the array using the name in mdadm.conf, and then rebuilding 
> mdadm.conf based on the name it got from mdadm.conf.
>>
>> I do not ever get md127.
>>
> If you boot with no mdadm.conf whatsoever? If that gives you md127, then 
> you can rename the arrays on the old system by messing with mdadm.conf.
> 
> Also, it's just struck me, you're matching array to name using the UUID. 
> So, assuming that's the array UUID (what else could it be) when you dd 
> the root filesystem across and boot, that array should NOT be called 
> md0, because the UUIDs won't match.
> 
> Cheers,
> Wol

I avoid UUID issues for rootfs by image copying partitions across the 
systems. I always have two installation in any each machine in two 
different partitions. One natively installed using distros USB (safeos) 
and one that is transferred from old system using image copy (masteros). 
This way I have a back up OS to boot and fix any mistakes I make.

I boot safeos and make the image copy of masteros. Mount copied system 
root, fix things like hostname, NIC name etc. I also fix 
fstab/mdadm.conf and a few other things that will cause errors when I 
boot that system.

After that I update-grub to add masteros to safeos bootmeny and reboot 
into masteros and update-grub and update-initramfs -u on the masteros, 
and reboot back into masteros. Now I start fixing any missing pieces. 
BTW, I did have md127 when I first booted masteros and it went back to 
/dev/md0 after I updated initramfs on masteros and rebooted. This, 
incidentally matches the note Reindl made.

I can give you more details, if that will help understand better what I 
have. This I do because I understand unix side and not mythtv side 
enough to fix issues on the latter. So, I always make image copies to 
keep mythtv happy. After all that is the purpose of this system.

Regards
Ramesh




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

* Re: Renaming md raid and moving md raid to a different machine.
  2023-03-20  8:35           ` Reindl Harald
@ 2023-03-20 22:23             ` Ram Ramesh
  0 siblings, 0 replies; 11+ messages in thread
From: Ram Ramesh @ 2023-03-20 22:23 UTC (permalink / raw)
  To: Reindl Harald, Wol, Linux Raid

On 3/20/23 03:35, Reindl Harald wrote:
> 
> 
> Am 20.03.23 um 01:34 schrieb Ram Ramesh:
>> Yes the names must be in the metadata of the md because I populate 
>> mdadm.conf after every change by actually using the output from mdadm 
>> --detail -scan. Since that comes up with md0/md1/md2, I assume somehow 
>> mdadm simply finds them again and again with exact same name.
>>
>> I do not ever get md127
> 
> no - your mdadm.conf is in the initrd because how else should the rootfs 
> could live on the array containing mdadm.conf

Agreed.  After I moved the rootfs of the old system to new hardware (a 
new machine with is two nvme raid1), I booted into it and it did show 
that the rootfs is on md127. However, after making mdadm.conf entries 
and update-initramfs, md name changed to /dev/md0. So, it must be what 
you said.

Regards
Ramesh


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

end of thread, other threads:[~2023-03-20 22:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <f237651e-536a-e305-8c1c-475e4c14d906@gmail.com>
2023-03-19 18:58 ` Renaming md raid and moving md raid to a different machine Ram Ramesh
2023-03-19 19:29   ` Reindl Harald
2023-03-19 19:52     ` Ram Ramesh
2023-03-19 22:51   ` Wol
2023-03-19 23:29     ` Ram Ramesh
2023-03-20  0:01       ` Wol
2023-03-20  0:34         ` Ram Ramesh
2023-03-20  8:00           ` Wols Lists
2023-03-20 14:53             ` Ram Ramesh
2023-03-20  8:35           ` Reindl Harald
2023-03-20 22:23             ` Ram Ramesh

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