仅从 RAID1 单磁盘恢复数据

仅从 RAID1 单磁盘恢复数据
root@rescue:~# fdisk -l

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1           69632 102713344 102643713    49G 83 Linux
/dev/sda2       102782976 467808255 365025280 174.1G fd Linux raid autodetect
/dev/sda3       467808256 468854783   1046528   511M 82 Linux swap / Solaris

Disk /dev/sdb: 223.6 GiB, 240057409536 bytes, 468862128 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: 0xf5bbee69

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1           69632 102713344 102643713    49G 83 Linux
/dev/sdb2       102782976 467808255 365025280 174.1G fd Linux raid autodetect
/dev/sdb3       467808256 468854783   1046528   511M 82 Linux swap / Solaris

Disk /dev/md0: 479 MiB, 502267904 bytes, 980992 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
Disk /dev/md1: 48.9 GiB, 52520026112 bytes, 102578176 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

root@rescue:~# lsblk 
NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sdb       8:16   0 223.6G  0 disk  
├─sdb2    8:18   0 174.1G  0 part  
├─sdb3    8:19   0   511M  0 part  
└─sdb1    8:17   0    49G  0 part  
  └─md1   9:1    0  48.9G  0 raid1 
sda       8:0    0 223.6G  0 disk  
├─sda2    8:2    0 174.1G  0 part  
├─sda3    8:3    0   511M  0 part  
│ └─md0   9:0    0   479M  0 raid1 
└─sda1    8:1    0    49G  0 part  
  └─md1   9:1    0  48.9G  0 raid1 

这里,磁盘 /dev/sdb 出现故障,因此我们不得不用新的 /dev/sdb 替换它。之后我们就无法挂载它了。

root@rescue:~# mount /dev/md1 /mnt
NTFS signature is missing.
Failed to mount '/dev/md1': Invalid argument
The device '/dev/md1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

我不知道为什么它显示 NTFS。是否可以删除 /dev/sdb 并仅从 /dev/sda 检索数据?

更新 1

root@rescue:~# cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty] 
md1 : active raid1 sda1[0]
      51289088 blocks super 1.2 [2/1] [U_]

unused devices: <none>

root@rescue:~# mdadm -D /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Thu Oct 17 00:56:45 2019
     Raid Level : raid1
     Array Size : 51289088 (48.91 GiB 52.52 GB)
  Used Dev Size : 51289088 (48.91 GiB 52.52 GB)
   Raid Devices : 2
  Total Devices : 1
    Persistence : Superblock is persistent

    Update Time : Thu Oct 17 00:56:45 2019
          State : clean, degraded 
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           Name : rescue.ovh.net:1  (local to host rescue.ovh.net)
           UUID : 0e4f4fb1:e750b67a:6db391a3:a9f6501e
         Events : 0

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       2       0        0        2      removed

更新 2

# mount /dev/md11 /test
NTFS signature is missing.
Failed to mount '/dev/md11': Invalid argument
The device '/dev/md11' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

答案1

您需要设置新的 sdb,它不会神奇地自动配置。RAID 部分仅镜像 sda2 的内部数据,而不是分区表和其他分区。

在你的情况下它看起来像:

sfdisk -d /dev/sda |sfdisk /dev/sdb      # clone sda partition table into sdb
mkswap /dev/sdb3
mdadm --add /dev/md0 /dev/sdb3

我不知道该如何处理这个孤独的 sdb1,我认为最好忘掉它,但请记住,您没有冗余的 /boot 分区,因此如果 sda 磁盘发生故障,您将无法启动。大多数引导加载程序都可以接受 RAID1 /boot 分区,您应该支持此设置。

编辑:误读了你的奇怪的突袭设置:

  • 它实际上是 md0=sda3+sdb3 (你的大分区)
  • 你在 RAID1 上确实有 /boot,并且 md1=sda+sdb1,但你的分区类型是错误的,它应该是“Linux raid autodetect”,就像 sda2 一样
  • 你的 md0 阵列不连贯, lsblk 显示 sda3 作为成员但它是一个交换分区,没有任何意义...

相关内容