mdadm apparently using wrong UUID

Kernels, Network, and Services configuration
Post Reply
Message
Author
dwasi
Posts: 27
Joined: 2019-11-27 16:57

mdadm apparently using wrong UUID

#1 Post by dwasi »

Moving a RAID1 array from one machine to another. blkid shows this information for the two drives:

Code: Select all

/dev/sdb1: UUID="007af4d0-f6d5-5009-5429-c084f86f0c5c" UUID_SUB="6472ee1b-b25c-9573-6929-745d73677be7" LABEL="Oberon:0" TYPE="linux_raid_member" PARTUUID="c3a4f240-4283-a741-9f76-1c2ea7f04077"
/dev/sdc1: UUID="007af4d0-f6d5-5009-5429-c084f86f0c5c" UUID_SUB="89b3c123-e494-2559-57d5-f5f238e732b9" LABEL="Oberon:0" TYPE="linux_raid_member" PARTUUID="49f3f666-0b0e-7244-9881-cd1f5dad4b88"
So naturally I set up /etc/mdadm/mdadm.conf like this and ran update-initramfs -u:

Code: Select all

# mdadm.conf
#
# !NB! Run update-initramfs -u after updating this file.
# !NB! This will ensure that initramfs has an uptodate copy.
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays
ARRAY /dev/md/0  metadata=1.2 UUID=007af4d0-f6d5-5009-5429-c084f86f0c5c name=Oberon:0

# This configuration was auto-generated on Mon, 08 Jun 2020 07:58:16 -0500 by mkconf
And added this line to /etc/fstab:

Code: Select all

UUID=007af4d0-f6d5-5009-5429-c084f86f0c5c	/storage	ext4	errors=remount-ro	0	1
This resulted in the system failing to complete the drive mount target and dropping to emergency mode. Investigating, I found the array was up, but with an entirely different UUID shown by blkid:

Code: Select all

/dev/md0: UUID="364fa0a8-d435-4192-b4a1-d58ab6c1bdc3" TYPE="ext4"
As an experiment, I tried changing the device name in mdadm.conf:

Code: Select all

# definitions of existing MD arrays
ARRAY /dev/md/1  metadata=1.2 UUID=007af4d0-f6d5-5009-5429-c084f86f0c5c name=Oberon:0
I ran update-initramfs -u again and rebooted, and blkid showed this:

Code: Select all

/dev/md1: UUID="364fa0a8-d435-4192-b4a1-d58ab6c1bdc3" TYPE="ext4"
So it is looking at mdadm.conf for the device name, but for some reason it's not using the UUID specified. It's generated a different one, but it appears to be using it consistently.

To get the system working, I surrendered on the UUID in fstab:

Code: Select all

UUID=364fa0a8-d435-4192-b4a1-d58ab6c1bdc3	/storage	ext4	errors=remount-ro	0	1
This works, but I don't know why it works, or more to the point, I don't know why it doesn't work as I expected. I've moved arrays before and never had this problem.

Any ideas?

p.H
Posts: 1891
Joined: 2017-09-17 07:12

Re: mdadm apparently using wrong UUID

#2 Post by p.H »

There are actually two different UUIDs used for different purposes.
- 007af4d0-f6d5-5009-5429-c084f86f0c5c is the RAID UUID used by mdadm to assemble the array. It is associated to the RAID member devices, /dev/sdb1 and /dev/sdc1.
- 364fa0a8-d435-4192-b4a1-d58ab6c1bdc3 is the filesystem UUID of the RAID array contents, used to mount the filesystem. It is associated to the RAID array /dev/md0 (or /dev/md1).

When you want to mount a filesystem in /etc/fstab, you must use the filesystem UUID.

dwasi
Posts: 27
Joined: 2019-11-27 16:57

Re: mdadm apparently using wrong UUID

#3 Post by dwasi »

p.H wrote:There are actually two different UUIDs used for different purposes.
- 007af4d0-f6d5-5009-5429-c084f86f0c5c is the RAID UUID used by mdadm to assemble the array. It is associated to the RAID member devices, /dev/sdb1 and /dev/sdc1.
- 364fa0a8-d435-4192-b4a1-d58ab6c1bdc3 is the filesystem UUID of the RAID array contents, used to mount the filesystem. It is associated to the RAID array /dev/md0 (or /dev/md1).

When you want to mount a filesystem in /etc/fstab, you must use the filesystem UUID.
I must be losing my shit.

I just moved another array yesterday, and it worked right, and I thought I had used the same UUID throughout. But, returning and checking it, I see it's the same as this; and somehow I managed to do it right one day and confused the UUIDs the next.

Maybe I should retire. :P

Thanks for the help.

Post Reply