我创建了一个 RAID 1 配置,我将其命名为 /dev/md1,但是当我重新启动时,名称总是更改为 /dev/md127
我找不到已创建 RAID 1 配置的解决方案,因此请备份您的数据,因为对于此解决方案,我将提供您需要先删除 RAID 1。实际上,我只是删除了我正在使用的虚拟机并创建了一个新的虚拟机。
所以这将适用于 Debian 10 和一台干净的机器
就我而言,我有 3 个虚拟磁盘,所以我运行这样的命令(请记住,首先您需要创建相同大小的分区并键入 Linux raid autodetect)
sudo mdadm --create /dev/md1 --level=mirror --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
Run Code Online (Sandbox Code Playgroud)
转到该文件/etc/mdadm/mdadm.conf
,删除所有内容,然后将其替换为:
# 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
Run Code Online (Sandbox Code Playgroud)
以 root 身份登录并执行此操作
sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Run Code Online (Sandbox Code Playgroud)
现在这个文件的内容是
# 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
Run Code Online (Sandbox Code Playgroud)
ARRAY /dev/md1 metadata=1.2 name=buster:1 UUID=1279dbd2:d0acbb4f:0b34e3e1:3de1b3af(这是添加的引用数组的新行)
如果该命令在 ARRAY 行之前添加了某些内容,请将其删除。
跑 sudo update-initramfs -u
挂载它是可选的,但我认为这会使用 RAID1 的存储。
sudo blkid
/etc/fstab
使用这一行新代码进行编辑,UUID=d367f4ed-2b37-4967-971a-13d9129fff4f /home/vagrant/raid1 ext3 defaults 0 2
将 UUID 替换为分区中的 UUID,将文件系统替换为分区中的 UUID我/etc/fstab
现在的内容是
# /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
Run Code Online (Sandbox Code Playgroud)
UUID=d367f4ed-2b37-4967-971a-13d9129fff4f /home/vagrant/raid1 ext3 defaults 0 2 (这里你可以清楚地看到我添加的那一行)
现在这个名字不会改变。
如果我运行,sudo fdisk -l
我会得到这个(我将只显示相关信息)
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
Run Code Online (Sandbox Code Playgroud)
如果我跑df -Th
我得到
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
Run Code Online (Sandbox Code Playgroud)
你看那也挂载了。最后,如果我跑cat /proc/mdstat
,我得到
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdd1[2] sdc1[1] sdb1[0]
1046528 blocks super 1.2 [3/3] [UUU]
unused devices: <none>
Run Code Online (Sandbox Code Playgroud)
raid1 正在使用 sdb1、sdc1 和 sdd1。
现在完成了!您可以重新启动,您的团队名称将始终保留。
https://superuser.com/questions/287462/how-can-i-make-mdadm-auto-assemble-raid-after-each-boot
https://ubuntuforums.org/showthread.php?t=2265120
https: //askubuntu.com/questions/63980/how-do-i-rename-an-mdadm-raid-array
https://serverfault.com/questions/267480/how-do-i-rename-an-mdadm-raid -array
https://bugzilla.redhat.com/show_bug.cgi?id=606481
有些比其他解决方案更相关,但所有这些都帮助我找到了这个解决方案。
哇,你读了很多不是吗?如果您的问题解决了,现在您可以放心了,希望这对您有所帮助!再见!
对于 Debian 11 系统,需要做的就是:
mdadm --detail --scan /dev/md127 >> /etc/mdadm/mdadm.conf
vim /etc/mdadm/mdadm.conf
,将附加行编辑为如下所示:
ARRAY /dev/md0 元数据=1.2 UUID=XXXXXXXX:XXXXXXXX:XXXXXXXX:XXXXXXXX
换句话说,移除该name
部件,然后将设备设置为/dev/md0
。
update-initramfs -u
重启
归档时间: |
|
查看次数: |
4162 次 |
最近记录: |