[SOLVED] Use UUID of HDDs in RAID 1 Array

Issues related to applications and software problems
Post Reply
simon_lefisch
Posts: 92
Joined: 2017/07/12 21:02:02

[SOLVED] Use UUID of HDDs in RAID 1 Array

Post by simon_lefisch » 2019/06/29 17:42:39

Hey everyone,

I've been searching the interwebs for an answer to my but for whatever reason I am unable to find a clear solution.

I currently have a RAID 1 array composed of 2 x 4TB HDDs. It is configured using /dev/sdb and /dev/sdc. However I would like to change this config to use the UUIDs of each device instead since the /dev/sd* can change when adding extra storage devices. Is there any way to be able to do this with the current config or will I have to nuke the array and start over?

Btw, the reason for wanting to use the UUID is I'm trying to add another HDD for a VM, but when I boot my server I get an error saying my array is degraded. It is due to the array using /dev/sd* for device identifier and when I added the extra HDD it used /dev/sdc.
Last edited by simon_lefisch on 2019/07/02 22:15:10, edited 1 time in total.
Hardware:
Supermicro X10SRi-F mobo
E5-2683v4 16-core CPU
112GB ECC RAM
2x 250GB SSD RAID1 (current CentOS 7 version)
2x 500GB SSD RAID1 (VM Disk Image Storage)
2x 4TB HDD RAID1 (Backup Storage via FreeNAS VM)
2X 6TB HDD RAID1 (Data Storage via FreeNAS VM)

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Use UUID of HDDs in RAID 1 Array

Post by TrevorH » 2019/06/29 17:48:09

Sure, it's the default way of setting it up anyway and there should be no problem changing over. If you edit /etc/mdadm.conf to look something like this you should be good to go. Use the UUID from mdadm --detail /dev/md0 | grep -i uuid

Code: Select all

$ cat /etc/mdadm.conf
ARRAY /dev/md/0  metadata=1.2 UUID=12318cc4:45663f68:789c462b:abc6c778 name=trevor9.trevor.local:1
MAILADDR trevor.h@my.email
Edit: if you have data on the array that is required by the boot process then you may need yo alter the kernel command line in /boot/grub2/grub.cfg to add rd.md.uuid=<md raid uuid> but if it works now then it's probably ok.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

simon_lefisch
Posts: 92
Joined: 2017/07/12 21:02:02

Re: Use UUID of HDDs in RAID 1 Array

Post by simon_lefisch » 2019/06/29 18:27:55

TrevorH wrote:
2019/06/29 17:48:09
Sure, it's the default way of setting it up anyway and there should be no problem changing over. If you edit /etc/mdadm.conf to look something like this you should be good to go. Use the UUID from mdadm --detail /dev/md0 | grep -i uuid

Code: Select all

$ cat /etc/mdadm.conf
ARRAY /dev/md/0  metadata=1.2 UUID=12318cc4:45663f68:789c462b:abc6c778 name=trevor9.trevor.local:1
MAILADDR trevor.h@my.email
Edit: if you have data on the array that is required by the boot process then you may need yo alter the kernel command line in /boot/grub2/grub.cfg to add rd.md.uuid=<md raid uuid> but if it works now then it's probably ok.
Hi Trevor,

Thanks for responding. Not sure if my question made sense or if I'm not understanding your answer, so apologies. Here is the output of mdadm --detail /dev/md0 | grep -i uuid:

Code: Select all

ARRAY /dev/md/0 level=raid1 num-devices=2 metadata=1.2 name=server:0 UUID=a0f4b81c:f32bd676:14105dbd:09292f38
   devices=/dev/sdb,/dev/sdc
MAILADDR my.email@address.com
As you can see, the array consists of devices sdb and sdc. However instead of using those device identifiers for the array, I would like to use the UUIDs of sdb and sdc. Does that clarify what I'm trying to do?
Hardware:
Supermicro X10SRi-F mobo
E5-2683v4 16-core CPU
112GB ECC RAM
2x 250GB SSD RAID1 (current CentOS 7 version)
2x 500GB SSD RAID1 (VM Disk Image Storage)
2x 4TB HDD RAID1 (Backup Storage via FreeNAS VM)
2X 6TB HDD RAID1 (Data Storage via FreeNAS VM)

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Use UUID of HDDs in RAID 1 Array

Post by TrevorH » 2019/06/29 19:11:02

What's currently in your /etc/mdadm.conf? It can use device names like /dev/sd[ab] or it can use UUIDs. I showed my example file that's using uuids so you would need to adapt yours to match. The metadata= bit cannot be changed as that would need a complete rebuild to implement, the rest can be.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

simon_lefisch
Posts: 92
Joined: 2017/07/12 21:02:02

Re: Use UUID of HDDs in RAID 1 Array

Post by simon_lefisch » 2019/06/29 19:23:00

TrevorH wrote:
2019/06/29 19:11:02
What's currently in your /etc/mdadm.conf? It can use device names like /dev/sd[ab] or it can use UUIDs. I showed my example file that's using uuids so you would need to adapt yours to match. The metadata= bit cannot be changed as that would need a complete rebuild to implement, the rest can be.
Apologies Trevor, the output of mdadm --detail /dev/md0 | grep -i uuid is:

Code: Select all

UUID : a0f4b81c:f32bd676:14105dbd:09292f38
My /etc/mdadm.conf is:

Code: Select all

ARRAY /dev/md/0 level=raid1 num-devices=2 metadata=1.2 name=server:0 UUID=a0f4b81c:f32bd676:14105dbd:09292f38
   devices=/dev/sdb,/dev/sdc
MAILADDR my.email@address.com
Sorry for the confusion of output.
Hardware:
Supermicro X10SRi-F mobo
E5-2683v4 16-core CPU
112GB ECC RAM
2x 250GB SSD RAID1 (current CentOS 7 version)
2x 500GB SSD RAID1 (VM Disk Image Storage)
2x 4TB HDD RAID1 (Backup Storage via FreeNAS VM)
2X 6TB HDD RAID1 (Data Storage via FreeNAS VM)

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Use UUID of HDDs in RAID 1 Array

Post by TrevorH » 2019/06/29 19:38:30

I am about 99% sure that you can just remove the devices=/dev/sdb,/dev/sdc bit of that. The UUID that is already there should be enough - it matches the one from your mdadm --detail. If you are concerned about it, make a backup copy of the file as it is now and make sure that you have an install DVD handy and you can boot that in rescue mode (an option off the initial Troubleshooting menu) and copy the backup copy back.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

simon_lefisch
Posts: 92
Joined: 2017/07/12 21:02:02

Re: Use UUID of HDDs in RAID 1 Array

Post by simon_lefisch » 2019/06/29 20:00:01

TrevorH wrote:
2019/06/29 19:38:30
I am about 99% sure that you can just remove the devices=/dev/sdb,/dev/sdc bit of that. The UUID that is already there should be enough - it matches the one from your mdadm --detail. If you are concerned about it, make a backup copy of the file as it is now and make sure that you have an install DVD handy and you can boot that in rescue mode (an option off the initial Troubleshooting menu) and copy the backup copy back.
Thanks Trevor, I will give that a shot. Currently out and about so I will let you know what happens when I get back.

I also just came across something that uses the UUID of the array and the disks by ID in fstab like this:

Code: Select all

UUID=a0f4b81c:f32bd676:14105dbd:09292f38       /mnt/raid1    ext4   auto,noatime,nodiratime,device=/dev/disk/by-id/ata-TOSHIBA_MD04ACA400_26F4KJ1NFSAA,device=/dev/disk/by-id/ata-TOSHIBA_MD04ACA400_26F4KJ1OFSAA    0       0
What do think about that? If that works, would I need to change anything? My current fstab entry for the array is:

Code: Select all

/dev/md0		/mnt/raid1		ext4	defaults	0 0
Hardware:
Supermicro X10SRi-F mobo
E5-2683v4 16-core CPU
112GB ECC RAM
2x 250GB SSD RAID1 (current CentOS 7 version)
2x 500GB SSD RAID1 (VM Disk Image Storage)
2x 4TB HDD RAID1 (Backup Storage via FreeNAS VM)
2X 6TB HDD RAID1 (Data Storage via FreeNAS VM)

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Use UUID of HDDs in RAID 1 Array

Post by TrevorH » 2019/06/29 20:32:26

UUIDs also work well in fstab and can help avoid things like the device name of /dev/md0 changing. It won't be the _same_ uuid
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

simon_lefisch
Posts: 92
Joined: 2017/07/12 21:02:02

Re: Use UUID of HDDs in RAID 1 Array

Post by simon_lefisch » 2019/07/02 22:07:31

TrevorH wrote:
2019/06/29 20:32:26
UUIDs also work well in fstab and can help avoid things like the device name of /dev/md0 changing. It won't be the _same_ uuid
Hi Trevor,

Sorry for the late response. I did what you said as far as removing the devices line in my mdadm.conf file and that worked perfectly!. Thanks for your help, it is much appreciated :mrgreen:
Hardware:
Supermicro X10SRi-F mobo
E5-2683v4 16-core CPU
112GB ECC RAM
2x 250GB SSD RAID1 (current CentOS 7 version)
2x 500GB SSD RAID1 (VM Disk Image Storage)
2x 4TB HDD RAID1 (Backup Storage via FreeNAS VM)
2X 6TB HDD RAID1 (Data Storage via FreeNAS VM)

Post Reply