On 2/11/22 09:34, Rich Shepard wrote:
On Fri, 11 Feb 2022, Tomas Kuchta wrote:

The point about not using /dev/sd*, especially with external enclosures,
is that the device letter can change (not just once) during the array
build.

Tomas,

I'll kill the mdadm create process and use the two UUIDs instead. Do I
write:
mdadm --create /dev/md0 -l 1 -n 2 UUID1 UUID2

or /dev/UUID1 /dev/UUID2?

Wait!  I think you are missing an important point.  UUIDs are used for many 
things
on a modern Linux system.  There will typically be *multiple* UUIDs used for
multiple purposes.  Here is some trimmed output from an Ubuntu system that has
three physical disks.  sda is the disk that contains the root filesystem, along
with some others.  sdb and sdc are part of a raid1 array that contains a
filesystem that is mounted under /backups

galens@oz:~$ cat /etc/fstab
UUID=565ba7ed-0474-4601-ba4a-64b74d1ad2bd /               ext4    
errors=remount-ro 0       1
UUID=37c7b397-6ceb-4a83-8120-012bdb3e3260 /backups              ext4    
defaults        0 2

Note that the UUIDs used in fstab are *filesystem* UUIDs.  These are different
from an mdraid UUID, a partition UUID, or other UUIDs.  The blkid command gives
the bigger picture.

galens@oz:~$ sudo blkid
/dev/sda1: UUID="565ba7ed-0474-4601-ba4a-64b74d1ad2bd" TYPE="ext4" 
PARTUUID="58d10f2d-01"
/dev/sda5: UUID="93c54ee7-e832-4b77-8dfd-920eb740dfdb" TYPE="swap" 
PARTUUID="58d10f2d-05"
/dev/sdb1: UUID="716039ff-eb41-9a09-9dd0-30c48a77d7dd" UUID_SUB="3e3da9b0-a476-3eec-4d7b-93936071817e" 
LABEL="oz:0" TYPE="linux_raid_member" PARTLABEL="p1" PARTUUID="1ba2b9b0-81c8-44b6-9399-a7ac5a44e80c"
/dev/sdc1: UUID="716039ff-eb41-9a09-9dd0-30c48a77d7dd" UUID_SUB="0249e1ef-2337-1437-39ba-842170377019" 
LABEL="oz:0" TYPE="linux_raid_member" PARTLABEL="p1" PARTUUID="ecc07d3d-9a28-44e1-b1a0-3be1c60d7f8c"
/dev/md0: UUID="37c7b397-6ceb-4a83-8120-012bdb3e3260" TYPE="ext4"

See how sda1 has both a filesystem UUID and a partition UUID.  Similarly, md0 
has
a filesystem UUID, as it contains a filesystem, but no partition UUID.

sdb1 and sdc1 are both used to create md0.  They are both (GPT) partitions on 
physical
disks, so they each have a unique partition UUID.  UUID_SUB is a device UUID and
is unique for both sdb1 and sdc1.  This leaves UUID="7160...  This is the mdraid
array UUID.  Note how it is the same for both sdb1 and sdc1.
This is how mdadm is able to group the appropriate disks together.  See
mdadm.conf

galens@oz:~$ cat /etc/mdadm/mdadm.conf
ARRAY /dev/md0 UUID=716039ff:eb419a09:9dd030c4:8a77d7dd

When you initially create the mdraid array, I *think* that these UUIDs are
automatically created.  You can check each disk partition like this:

galens@oz:~$ sudo mdadm --examine /dev/sdb1 | grep UUID
     Array UUID : 716039ff:eb419a09:9dd030c4:8a77d7dd
    Device UUID : 3e3da9b0:a4763eec:4d7b9393:6071817e


Whenever I have set up a raid1 array, it has been at distribution install
time, so the Ubuntu or CentOS tools have done it for me.  That said, I
think you should be able create the raid array using the partition names
(e.g. /dev/sdxN, /dev/sdyM, etc.), and then find the array UUID using
mdadm --examine.  Once you have the array UUID, you can drop it into
mdadm.conf.  This should make your raid array independent of any sdxN
naming.  Then you can create a filesystem on mdx.  This will create
a filesystem UUID, which you then put into fstab in order to mount
the filesystem.

Note that if you were using LVM, there would also be UUIDs associated
with that as well.


galen
--
Galen Seitz
gal...@seitzassoc.com

Reply via email to