恢复 RAID 阵列

恢复 RAID 阵列

我意外地通过强制重启(在第 5 个硬盘上)损坏了我的 Ubuntu 17.10 版本。在我的系统中,我有 4 个其他硬盘,它们属于 RAID5 阵列。现在我再次安装了 Ubuntu 17.10,如何恢复我的阵列和数据?

我都试过了

sudo mdadm --assemble --uuid=XXXXXXXXXX

sudo mdadm --assemble /dev/md0 /dev/sdb /dev/sdc /dev/sdd /dev/sde

然后我可以将其挂载,但当我访问文件时,它会提示输入密码,并且文件夹是空的。所有阵列成员都显示为活动和干净。

注意:在崩溃之前,我已将 /home 目录移至此 RAID 并将其挂载到那里。请参见以下输出:

cat /proc/mdstat 

Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10] 
md0 : active raid5 sde[4] sdb[0] sdd[2] sdc[1] 8790405120 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU] 
bitmap: 0/22 pages [0KB], 65536KB chunk 
unused devices: <none> 

下面的输出

sudo parted --list /dev/md0

Model: ATA TS128GSSD370S (scsi)
Disk /dev/sda: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name                  Flags
 1      1049kB  538MB  537MB  fat32        EFI System Partition  boot, esp
 2      538MB   128GB  127GB  ext4


Error: end of file while reading /dev/sdb
Retry/Ignore/Cancel? retry
Error: end of file while reading /dev/sdb
Retry/Ignore/Cancel? ignore                                               
Error: The primary GPT table is corrupt, but the backup appears OK, so that will
be used.
OK/Cancel? ok                                                             
Model: ATA ST3000VN000-1HJ1 (scsi)
Disk /dev/sdb: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  Flags


Error: /dev/sdc: unrecognised disk label
Model: ATA ST3000VN000-1HJ1 (scsi)                                        
Disk /dev/sdc: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags: 

Error: /dev/sdd: unrecognised disk label
Model: ATA ST3000VN000-1HJ1 (scsi)                                        
Disk /dev/sdd: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags: 

Error: end of file while reading /dev/sde
Retry/Ignore/Cancel? ignore
Error: The primary GPT table is corrupt, but the backup appears OK, so that will
be used.
OK/Cancel? ok                                                             
Model: ATA ST3000VN000-1HJ1 (scsi)
Disk /dev/sde: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start  End  Size  File system  Name  Flags


Model: WD Elements 25A1 (scsi)
Disk /dev/sdf: 3001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name      Flags
 1      1049kB  3001GB  3001GB  ntfs         Elements  msftdata


Model: Linux Software RAID Array (md)
Disk /dev/md0: 9001GB
Sector size (logical/physical): 512B/4096B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  9001GB  9001GB  ext4

挂载 /dev/md0 /mnt 之后

ls -la /dev/md* 的输出是

brw-rw---- 1 root disk 9, 0 Apr 13 16:31 /dev/md0

/dev/md:
total 0
drwxr-xr-x  2 root root   60 Apr 13 16:31 .
drwxr-xr-x 21 root root 4520 Apr 13 16:31 ..
lrwxrwxrwx  1 root root    6 Apr 13 16:31 0 -> ../md0

答案1

这不是 raid 问题,更多的是权限问题。如果您检查命令的输出cat /proc/mdstat,您可以看到 raid5 已完美组装,如行[UUUU]中所示md0

Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10]
md0 : active raid5 sde[4] sdb[0] sdd[2] sdc[1] 8790405120 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]
bitmap: 0/22 pages [0KB], 65536KB chunk
unused devices: <none>

分区表(循环设备的循环)和文件系统(ext4)也都很好。挂载循环设备后,mount /dev/md0 /mnt您应该会看到类似以下内容:

$ mount /dev/md0 /mnt
$ ls -la /mnt
  total 12
  drwxr-xr-x  3 root root 4096 Jun 29  2016 .
  drwxr-xr-x 10 root root 4096 Dec  7 10:42 ..
  drwxr-xr-x  3 1001 2001 4096 Feb  6  2017 oldusername

现在您需要将旧用户主页的所有者更改为您当前的用户:

$ sudo chown $(stat -c '%u:%g' ~/) /mnt/oldusername
$ ls -la /mnt
  total 12
  drwxr-xr-x  3 root        root         4096 Jun 29  2016 .
  drwxr-xr-x 10 root        root         4096 Dec  7 10:42 ..
  drwxr-xr-x  3 currentuser currentgroup 4096 Feb  6  2017 oldusername

相关内容