AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 535231
Accepted
Simon Lindgren
Simon Lindgren
Asked: 2013-08-31 11:20:43 +0800 CST2013-08-31 11:20:43 +0800 CST 2013-08-31 11:20:43 +0800 CST

mdadm --zero-superblock 在带有其他分区的磁盘上

  • 772

我有三个磁盘,用于保存 MD RAID5 阵列。我已经删除(或者我认为)这个数组并为 btrfs 和交换空间创建了分区。重新启动机器时,MD 仍然绑定用于保存旧阵列的设备,导致新文件系统无法挂载。

有人向我建议,可能会留下 RAID 阵列的旧超级块,导致 MD 认为它是一个真正的阵列,从而绑定磁盘。建议的解决方案是使用 mdadm --zero-superblock 清除受影响磁盘上的超级块。但是,我真的不知道这对磁盘有什么作用。由于该磁盘包含分区,因此我真的不想盲目地将其部分归零。

那么我应该遵循什么程序来安全地清除 MD 超级块而不损坏驱动器上的其他分区和文件系统?

这个问题本质上问的是同样的事情,但是对于在重新分区的设备上执行 mdadm --zero-superblock 是否实际上应该是安全的,并没有明确的答案:mdadm superblock hidden /shadowing partition

mdadm
  • 3 3 个回答
  • 51015 Views

3 个回答

  • Voted
  1. Best Answer
    GioMac
    2013-08-31T15:35:30+08:002013-08-31T15:35:30+08:00

    https://raid.wiki.kernel.org/index.php/RAID_superblock_formats

    The superblock is 4K long and is written into a 64K aligned block that starts at least 64K and less than 128K from the end of the device (i.e. to get the address of the superblock round the size of the device down to a multiple of 64K and then subtract 64K). The available size of each device is the amount of space before the super block, so between 64K and 128K is lost when a device in incorporated into an MD array.

    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

    • 6
  2. Michael Shigorin
    2016-03-04T04:24:05+08:002016-03-04T04:24:05+08:00

    wipefs --all /dev/sd[4ppropr14t3][123] (of course set up the glob for your drives/partitions!)

    • 3
  3. Simon Lindgren
    2013-08-31T15:29:57+08:002013-08-31T15:29:57+08:00

    这就是我想出的方法(它可能对我的情况非常具体,但我会尽量保持一般性)。

    (当我谈论设备时,我的意思是组成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:

    mdadm --stop $ONE_OF_THE_DEVICES
    

    Repeat this line as required

    mdadm --zero-superblock $DEVICE
    

    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.

    • 2

相关问题

  • 将 Linux 软件 RAID 1 扩展到 RAID 10 的最佳方法

  • 如何在没有备用的情况下创建软件 raid5 阵列

  • mdadm raid5 超级块丢失

  • 如何将 Linux 软件 RAID 移动到新机器上?

  • 有没有好的图形或基于 Web 的 md 状态或管理工具?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve