W
W
webpixel2020-04-24 17:42:03
linux
webpixel, 2020-04-24 17:42:03

How to recreate RAID1 without data loss?

Hello connoisseurs! Can you please tell me if it is possible to restore RAID1 without losing data? The situation is this, half a year ago there was a reboot, and apparently then the raid collapsed. Noticed just now. The sdA drive remained active, but this is what lsblk and /proc/mdstat now show:

NAME    MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda       8:0    0 931.5G  0 disk
├─sda1    8:1    0     1M  0 part
├─sda2    8:2    0   500M  0 part  /boot
├─sda3    8:3    0   7.8G  0 part  [SWAP]
├─sda4    8:4    0     1K  0 part
└─sda5    8:5    0 923.2G  0 part  /
sdb       8:16   0 931.5G  0 disk
├─sdb1    8:17   0   976M  0 part
│ └─md0   9:0    0 975.4M  0 raid1
├─sdb2    8:18   0   7.5G  0 part
│ └─md1   9:1    0   7.5G  0 raid1
└─sdb3    8:19   0 923.1G  0 part
  └─md2   9:2    0 922.8G  0 raid1


cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb1[1]
      998848 blocks super 1.2 [2/1] [_U]

md2 : active raid1 sdb3[1]
      967629824 blocks super 1.2 [2/1] [_U]
      bitmap: 0/8 pages [0KB], 65536KB chunk

md1 : active raid1 sdb2[1]
      7831552 blocks super 1.2 [2/1] [_U]

unused devices: <none>


it shows that the sdA has been removed from the raid and the sdB is active. As I understand it, for good, you need to delete the current md0-2 and recreate the raid, but is it possible to do this without losing data? To synchronize sdA -> sdB? Thanks a lot.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Armenian Radio, 2020-04-24
@gbg

No need to remove, just need to carefully replace the drive in the array.

V
Victor Taran, 2020-04-24
@shambler81

a bunch of articles
, so I wrote about 6 years ago
, I don’t think that everything has changed there.
https://klondike-studio.ru/blog/raid-recovery/

A
azrocketa, 2020-04-27
@azrocketa

If I understood correctly from all the comments and discussion of the problem, then you now have working data on /dev/sda which is mounted and in use, and there is also a raid1 from a single disk /dev/sdb which just exists.

As I understand it, for good, you need to delete the current md0-2 and recreate the raid, but is it possible to do this without losing data? To synchronize sdA -> sdB? Thanks a lot.

Not sure if this is possible on the fly. I would still plan to work with server downtime.
1) Boot from live_iso and transfer the actual data from /dev/sda5 to /dev/md2
2) You have boot on a separate partition, you also need to transfer the /boot/ partition to /dev/md2
3) Making sure that all the actual data is on / dev/md2, add /dev/sda to the current raid
(previously recreating the partitions sfdisk -d /dev/sdb | sfdisk /dev/sda)
4) After everything has been transferred to the raid, you need to chroot into the system on /dev/md2 and make update-grub from it, update the raid config /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
and you can reboot, but when booting, select the disk that is /dev/sdb so that the system starts booting from it.
It is better to wait for the full synchronization of the raid until the end, but this may be delayed.
Besides update-grub you can also do update-initramfs -k all -u -v
sometimes removing the current linux-image package and reinstalling it can help.
Essentially you need to migrate from disk to raid 1, so google howto for your linux distribution on how to migrate root properly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question