我有三个磁盘,用于保存 MD RAID5 阵列。我已经删除(或者我认为)这个数组并为 btrfs 和交换空间创建了分区。重新启动机器时,MD 仍然绑定用于保存旧阵列的设备,导致新文件系统无法挂载。
有人向我建议,可能会留下 RAID 阵列的旧超级块,导致 MD 认为它是一个真正的阵列,从而绑定磁盘。建议的解决方案是使用 mdadm --zero-superblock 清除受影响磁盘上的超级块。但是,我真的不知道这对磁盘有什么作用。由于该磁盘包含分区,因此我真的不想盲目地将其部分归零。
那么我应该遵循什么程序来安全地清除 MD 超级块而不损坏驱动器上的其他分区和文件系统?
这个问题本质上问的是同样的事情,但是对于在重新分区的设备上执行 mdadm --zero-superblock 是否实际上应该是安全的,并没有明确的答案:mdadm superblock hidden /shadowing partition
https://raid.wiki.kernel.org/index.php/RAID_superblock_formats
So, It's already too late and might be unsafe to use
--zero-superblock
, because we don't know is there any data or not - you must resize/shrink your current partition to-128K
from the end of the x-RAID partition, then, wipe that part and grow partition back.Other option 1: write large files to fill entire disk, it will overwrite RAID superblocks and it will not be recognizable by the mdadm.
Other option 2: similar to 1: https://unix.stackexchange.com/questions/44234/clear-unused-space-with-zeros-ext3-ext4
wipefs --all /dev/sd[4ppropr14t3][123]
(of course set up the glob for your drives/partitions!)这就是我想出的方法(它可能对我的情况非常具体,但我会尽量保持一般性)。
(当我谈论设备时,我的意思是组成raid 卷的设备,而不是raid 阵列本身)
我曾经
mdadm -E $DEVICE
弄清楚数组使用的是哪种元数据格式。然后我去了raid.wiki.kernel.org查找有关超级块格式的一些信息。就我而言,这是 0.90 版。This format has the superblock stored towards the end of the device. This is where my situation comes in. My old array was made directly on the drives, no partitioning. Because of this, I knew the superblock should be at the very end of the device. My new partitioning included a swap partition at the end. Therefore, there was not much data to lose where the superblock was located.
I did some reading around, the conclusion I reached was that
mdadm --zero-superblock
only zeroes out the superblock itself and thus it should be safe in my case. I went ahead and removed the superblocks on all three devices:Repeat this line as required
Some additional comments/speculation:
Generally, if the space is needed by the new partitioning/filesystems it should have been overwritten already. Thus, if the superblock still there, zeroing it shouldn't hurt the partitioning/filesystems. I am however not sure how MD handles the case where the superblock has already been overwritten on one or many of the devices but not all. The man page says that -f is needed to zero the superblock out if it is invalid, but keep it in mind.