mdadm - 全新安装后如何重建 raid 阵列?

mdadm - 全新安装后如何重建 raid 阵列?

我曾经在挂载点上有一个 raid1 阵列/mnt/md0,但是我重新安装了操作系统,现在我不知道如何重新组装它。

我相信我应该按照 的思路做一些事情mdadm --assemble,但我不知道如何将此信息添加到在重新启动之间保持不变的配置文件中。 (我也不记得配置文件的位置。)

我首先按照此信息创建了数组

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

但没有有关如何使用现有磁盘创建阵列的信息。

有人能指出我正确的方向吗?

更新:我找到了这个配置文件:/etc/mdadm/mdadm.conf

这就是它包含的内容

# 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

答案1

这其实是微不足道的。

操作系统重新安装(相同版本的 debian 10)似乎在安装过程中检测到 RAID 磁盘。它表明有 2 个磁盘处于某种 raid 模式。我认为因为它看到了这一点,它也在网络安装期间从网络上提取了相关的软件包......无论如何......

sudo mdadm --assemble --scan

这是(我猜?)填充配置文件的内容

这也是我的历史,但是大概不是需要的... sudo mdadm --assemble /dev/md0

然后安装(这就是我困惑的原因)

sudo mount /dev/md0 /mnt/md0

不知道这是否会在重新启动之间持续存在?可能不会。我不知道要投入什么/etc/fstab才能实现这一目标。

编辑:要在启动时安装,我遵循了这个https://askubuntu.com/questions/540202/mount-an-mdadm-raid-1-drive-at-boot

/dev/md0    /mnt/md0    ext4    defaults    0   0

答案2

通常,如果您有一个标记为任何类型的 raid 的磁盘,每个磁盘上都会有mdadm可以使用的元数据,因此当您扫描/组装时,它知道谁在使用该元数据以及在什么模式下使用。之后,它就是当时流行且很酷的安装语法。

除了什么罗杰·利普斯科姆说,”请注意,如果您的 RAID 卷已分区(我的是),您可能需要挂载/dev/md0p1而不是/dev/md0“,内核 5.18 破坏/更改了语法。由于您使用的是 Debian,因此可能会在您达到 5.18 之前一点,但请注意,如果您更新并且阵列不会挂载,这是因为语法发生了变化,而且更像是 Roger 的建议。

例如,我的 fstab 来自

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

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

相关内容