删除了 md0、md1 并且无法重新创建它们

删除了 md0、md1 并且无法重新创建它们

我以前有一个可用的 RAID 1 阵列。我认为由于运行grub-install /dev/sdbgrub-install /dev/sdc我以某种方式擦除了计算机上的md0md1

我需要重新设置它们。当我尝试创建md0数组时,出现以下错误。

/dev# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 missing -f
mdadm: device /dev/sda1 not suitable for any style of array

Debian 似乎认为驱动器已经在阵列中,但事实并非如此。

# fdisk -l

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000080

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       30064   241489048+  fd  Linux raid autodetect
/dev/sda2           30065       30394     2650725    5  Extended
/dev/sda5           30065       30394     2650693+  fd  Linux raid autodetect

# cat /proc/mdstat 
Personalities : [raid1] 
unused devices: <none>

编辑:请不要安装的输出。它似乎显示md0已安装在 中/,但为什么它没有显示在 中proc/mdstat

/dev/md0 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)

cat /proc/mounts 
rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
none /proc proc rw,nosuid,nodev,noexec,relatime 0 0
none /dev devtmpfs rw,relatime,size=4143896k,nr_inodes=204530,mode=755 0 0
none /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
/dev/sda1 / ext3 rw,relatime,errors=remount-ro,data=ordered 0 0
tmpfs /lib/init/rw tmpfs rw,nosuid,relatime,mode=755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev,relatime 0 0

file -s /dev/sda*
/dev/sda:  x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, stage2 address 0x2000, stage2 segment 0x200; partition 1: ID=0xfd, active, starthead 1, startsector 63, 482978097 sectors; partition 2: ID=0x5, starthead 254, startsector 482978160, 5301450 sectors, code offset 0x48, OEM-ID "      м", Bytes/sector 190, sectors/cluster 124, reserved sectors 191, FATs 6, root entries 185, sectors 64514 (volumes <=32 MB) , Media descriptor 0xf3, sectors/FAT 20644, heads 6, hidden sectors 309755, sectors 2147991229 (volumes > 32 MB) , physical drive 0x7e, dos < 4.0 BootSector (0x0)
/dev/sda1: Linux rev 1.0 ext3 filesystem data, UUID=38daaa54-a108-4224-9104-016d5b4ee12c (needs journal recovery) (large files)
/dev/sda2: x86 boot sector; partition 1: ID=0xfd, starthead 254, startsector 63, 5301387 sectors, extended partition table (last)\011, code offset 0x0
/dev/sda5: Linux/i386 swap file (new style), version 1 (4K pages), size 662655 pages, no label, UUID=f635267e-37f8-43d0-ad01-d25969570a8f

更多信息:我的工作 RAID 阵列有 md0 和 md1,驱动器为 sdb 和 sdc。我运行了这些grub-install命令。几天后,我尝试重新启动它,但收到以下错误(我认为对应于md0

Gave up waiting for boot device
ALERT /dev/disk/by-uuid/38[...] does not exist

所以我拔掉了第二个和第三个硬盘,当设置为 md0 时 GRUB 无法启动,所以我将其设置为,dev/sda1这就是我的机器当前所处的状态。

mdadm --assemble --scan -v -v
mdadm: looking for devices for /dev/md0
mdadm: /dev/sda5 has wrong uuid.
mdadm: no recogniseable superblock on /dev/sda2
mdadm: /dev/sda2 has wrong uuid.
mdadm: cannot open device /dev/sda1: Device or resource busy
mdadm: /dev/sda1 has wrong uuid.
mdadm: cannot open device /dev/sda: Device or resource busy
mdadm: /dev/sda has wrong uuid.
mdadm: looking for devices for /dev/md1
mdadm: /dev/sda5 requires wrong number of drives.
mdadm: no recogniseable superblock on /dev/sda2
mdadm: /dev/sda2 has wrong uuid.
mdadm: cannot open device /dev/sda1: Device or resource busy
mdadm: /dev/sda1 has wrong uuid.
mdadm: cannot open device /dev/sda: Device or resource busy
mdadm: /dev/sda has wrong uuid.


 sfdisk -d /dev/sda
# partition table of /dev/sda
unit: sectors

/dev/sda1 : start=       63, size=482978097, Id=fd, bootable
/dev/sda2 : start=482978160, size=  5301450, Id= 5
/dev/sda3 : start=        0, size=        0, Id= 0
/dev/sda4 : start=        0, size=        0, Id= 0
/dev/sda5 : start=482978223, size=  5301387, Id=fd

答案1

/dev/sda1已安装。安装后您将无法执行任何操作。重新启动至 Live CD。

您可以从现有文件系统创建 RAID1 卷,而不会丢失数据。它必须使用 0.9 或 1.0 超级块格式,因为默认的 1.2 格式需要将超级块放置在设备的开头附近,因此文件系统无法在同一位置启动。看如何设置磁盘镜像 (RAID-1)完整的演练。

您需要确保设备末端有足够的空间容纳超级块。超级块位于设备的最后 64kB 对齐的 64kB 中,因此根据设备大小,它可能位于设备末尾之前 64kB 到 128kB 之间的任何位置。运行tune2fs -l /dev/sda1并将“块计数”值乘以“块大小”值以获得文件系统大小(以字节为单位)。块设备的大小为 241489048½ kB,因此您需要将文件系统降至最多 241488960 kB。如果大于该值,请resize2fs /dev/sda1 241488960K在运行之前运行mdadm --create

如果文件系统足够短,您可以使用合适的元数据格式创建 RAID1 设备。

mdadm --create /dev/md0 --level=1 --raid-devices=2 --metadata=1.0 /dev/sda1 missing

答案2

您需要先使设备发生故障并将其删除,然后才能将其添加到另一个 RAID。

$ mdadm /dev/md0 -f /dev/sda1
$ mdadm /dev/md0 -r /dev/sda1

您还可以使用此命令查看当前的 RAID 设置:

$ mdadm --detail /dev/md0
/dev/md0:
        Version : 0.90
  Creation Time : Wed Dec 16 22:55:51 2009
     Raid Level : raid1
     Array Size : 2930266432 (2794.52 GiB 3000.59 GB)
  Used Dev Size : -1
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed Jul 24 02:05:22 2013
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 2d2c47de:dd4d678f:6a89fc71:2e8f3e64
         Events : 0.23916

    Number   Major   Minor   RaidDevice State
       0       8       33        0      active sync   /dev/sdc1
       1       8       17        1      active sync   /dev/sdb1

相关内容