I did a RAID1 to lvm for / partition but i forgot to RAID1 /boot and /boot/efi standard partition, how do i safely add the missing partitions into RAID1 array? click here for image of partitions
1 Answers
Disclaimer: I doubt the second picture RAID scheme is correct, since UEFI specification doesn't allow putting EFI System Partition (which is what is mounted as /boot/efi) under Linux MD RAID; such a system should not boot, or at least the booting could be unstable. However, answering solely to the question, it's possible to come into that second scheme without any downtime. During the process, the data will be stored only on the one device (sda), so have backups and check the health of the /dev/sda before you proceed. For instance, at least check the disk state with smartctl --all /dev/sda, then read the whole disk into nothing with dd if=/dev/sda of=/dev/zero status=progress (just to issue read operation to each sector to confirm it's readable), and then do the smartctl check again and compare attribute values, especially that here are no "pending relocations" and "offline uncorrectable". If there are, or dd fails with I/O read error, stop and ask further.
First of all, we need to partition the second device exactly the same way as the first one. For that, we need to release /dev/sdb1:
mdadm -f /dev/md127 /dev/sdb1
mdadm -r /dev/md127 /dev/sdb1
now your lsblk should not see any structure on sdb apart having a partition.
Then, copy the partitioning. First command reads the partition table from the first device and second creates the same on the second, changing any UUIDs:
sfdisk -d /dev/sda > /tmp/part_table
grep -v ^label-id /tmp/part_table | sed -e 's/, *uuid=[0-9A-F-]*//' | sfdisk /dev/sdb
Now, lsblk will show three partitions on sdb.
Next, add the partitions to proper RAIDs. Since the block device table you showed has only /dev/sda3 as a member of a RAID, it's the easiest to just add it:
mdadm --add /dev/md127 /dev/sdb3
It should start replicating data to sdb, and you can watch the progress with
watch cat /proc/mdstat
but you can continue right away, the copying will continue in the background. Linux limits this process to 200 Mb/sec by default, we can adjust it, but for 800 GB we probably don't need.
With other partitions the situation is different. Right now they aren't parts of any (degraded) RAID, and /dev/sda1 should not be RAID at all. Until you properly answer the comments up there, I won't explain how to convert them into RAID. For now, read how the ESP should be made redundant properly (e.g. not being a part of a RAID) in an system that is booting via UEFI.
You create a new FAT32 file system on /dev/sdb1 and copy its contents:
mkfs.vfat -F 32 /dev/sdb1
mkdir /tmp/esp2
mount /dev/sdb1 /tmp/esp2
cp -rf /boot/efi/ /tmp/esp2/
Then you need to install a firmware boot entry for the second ESP. If something is wrong, this may render the system unbootable and require the use of rescue boot media to fix. You can build efibootmgr command as described under the link I gave, or just install grub again into the new ESP:
grub-install --target=x86_64-efi --efi-directory=/tmp/esp2
Finally, we need to address the /boot redundancy. Until the comments are answered, I can't suggest any safe explanation.
- 15,624