I create a RAID 1 configuration, I name it /dev/md1, but when I reboot, the name always changes to /dev/md127
I couldn't find a solution with an already created RAID 1 configuration, so backup your data, because for this solution I'll give you'll need to delete your RAID 1 first. Actually, I just deleted the virtual machine I was working with and created a new one.
So this it's going to work with Debian 10, and with a clean machine
In my case I have 3 virtual disks, so I run the command like this (remember that first you need to make partitions of the same size and type Linux raid autodetect)
sudo mdadm --create /dev/md1 --level=mirror --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
Go to the file
/etc/mdadm/mdadm.conf, delete all content, and replace it with this instead:
# mdadm.conf # # Please refer to mdadm.conf(5) for information about this file. # DEVICE partitions # auto-create devices with Debian standard permissions CREATE owner=root group=disk mode=0660 auto=yes # 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
Login as root and do this
sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Now the contents of this file are
# mdadm.conf # # Please refer to mdadm.conf(5) for information about this file. # DEVICE partitions # auto-create devices with Debian standard permissions CREATE owner=root group=disk mode=0660 auto=yes # 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/md1 metadata=1.2 name=buster:1 UUID=1279dbd2:d0acbb4f:0b34e3e1:3de1b3af
ARRAY /dev/md1 metadata=1.2 name=buster:1 UUID=1279dbd2:d0acbb4f:0b34e3e1:3de1b3af (this was the new line added referencing the array)
If the command has added something before the ARRAY line, delete it.
sudo update-initramfs -u
Mount it it's optional, but I think that'll want to use the storage of your RAID1.
/etc/fstabwith this new line of code
UUID=d367f4ed-2b37-4967-971a-13d9129fff4f /home/vagrant/raid1 ext3 defaults 0 2Replace the UUID with the one you got of your partition, and the filesystem with the one you have in your partition
The contents of my
/etc/fstab now are
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/vda1 during installation UUID=b9ffc3d1-86b2-4a2c-a8be-f2b2f4aa4cb5 / ext4 errors=remount-ro 0 1 # swap was on /dev/vda5 during installation UUID=f8f6d279-1b63-4310-a668-cb468c9091d8 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0 UUID=d367f4ed-2b37-4967-971a-13d9129fff4f /home/vagrant/raid1 ext3 defaults 0 2
UUID=d367f4ed-2b37-4967-971a-13d9129fff4f /home/vagrant/raid1 ext3 defaults 0 2 (here you can see clearly the line I added)
The name now is not going to change.
If I run
sudo fdisk -l I get this (I'll show just the relevant information)
Disk /dev/md1: 1022 MiB, 1071644672 bytes, 2093056 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x37b2765e Device Boot Start End Sectors Size Id Type /dev/md1p1 2048 2093055 2091008 1021M 83 Linux
If I run
df -Th I get
Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 227M 0 227M 0% /dev tmpfs tmpfs 49M 3.4M 46M 7% /run /dev/sda1 ext4 19G 4.1G 14G 24% / tmpfs tmpfs 242M 0 242M 0% /dev/shm tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs tmpfs 242M 0 242M 0% /sys/fs/cgroup /dev/md1p1 ext3 989M 1.3M 937M 1% /home/vagrant/raid1 tmpfs tmpfs 49M 0 49M 0% /run/user/1000
You see that is also mounted. And finally, If I run
cat /proc/mdstat, I get
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] md1 : active raid1 sdd1 sdc1 sdb1 1046528 blocks super 1.2 [3/3] [UUU] unused devices: <none>
The raid1 is working, with sdb1, sdc1 and sdd1.
Now this is COMPLETE! You can reboot and your raid name will always remain.
Some are more relevant for this solution than others, but ALL OF THEM helped me reach this solution.
Wow, you have read a lot isn't it? Now you can relax if your problem was solved, hope this helped you out! See you!