2

I used to have a raid1 array on the mountpoint /mnt/md0, however I re-installed my OS and now I don't know how to re assemble it.

I believe I should be doing something along the lines of mdadm --assemble, but I don't know how to add this information into a configuration file which is persistent between reboots. (I don't recall the location of the config file either.)

I followed this information to create the array in the first place

https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-debian-9

but there is no info about how to create an array using existing disks.

Can someone point me in the right direction?

Update: I found this config file: /etc/mdadm/mdadm.conf

This is what it contains

# 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=(uuid here) name=(system name here):0

# This configuration was auto-generated on Fri, 19 Jun 2020 13:52:02 +0100 by mkconf

2 Answers 2

5

It was actually trivial.

The OS re-install (same version of debian 10) seemed to detect the RAID disks during the install. It indicated there were 2 disks which were in some kind of raid mode. I assume because it saw this it pulled the relevant packages from the web during the netinstall as well... Regardless...

sudo mdadm --assemble --scan

this is (I guess?) what populated the config file

This is also in my history, but probably not needed... sudo mdadm --assemble /dev/md0 ?

Then to mount (this is why I was confused)

sudo mount /dev/md0 /mnt/md0

No idea if this will be persistent between reboots? Probably not. I don't know what to put in /etc/fstab to accomplish this.

Edit: To mount at boot I followed this https://askubuntu.com/questions/540202/mount-an-mdadm-raid-1-drive-at-boot

/dev/md0    /mnt/md0    ext4    defaults    0   0
4
  • Note that if your RAID volume is partitioned (mine is), you might need to mount /dev/md0p1 rather than /dev/md0. Jun 6, 2022 at 10:16
  • sudo mdadm --assemble --scan worked perfectly for me to restore a 3x6TB software Raid 0 raid on Ubuntu 220.04. thanks! I had to install mdadm first though of course: sudo apt-get install mdadm Oct 27, 2022 at 14:42
  • you also don't need to manually edit /etc/fstab for auto mount. just fire up disks, click on the entry for the raid array, click the settings cog wheel, click edit mount options, unclick user session defaults and then select mount at system startup. be sure to configure your mount point option as well if you want it in a specific location. Oct 27, 2022 at 14:47
  • @fIwJlxSzApHEZIl Presumably this requires as GUI? Oct 27, 2022 at 16:02
0

Normally if you have a disk flagged as any type of raid there will be metadata on each disk that mdadm can use so when you scan/assemble it knows who goes with that and in what mode. After that it's just whatever mounting syntax happens to be hip and cool at the time.

In addition to what Roger Lipscombe said, "Note that if your RAID volume is partitioned (mine is), you might need to mount /dev/md0p1 rather than /dev/md0", kernel 5.18 breaks/changes the syntax. Since you're on Debian it might be a bit before you hit 5.18 but be aware if you update and the array won't mount it's because the syntax changed and it's more like Roger's suggestion.

For example, my fstab went from

/dev/md127p1 /home       ext4    errors=remount-ro 0       1

to

/dev/md0p1  /home   ext4    errors=remount-ro   0   1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.