How to create LVM RAID 1 with 4 disks of 2 different sizes?
That is heavily depends on what are you aiming at, because NVMe vs SATA SSD speeds & latency have a huge difference.
Personally, I would've created two different sets of LVM volume groups (VG). One for the NVMe and other for SSD and manually assigning them for a different tasks. I.e. NVMe for IO heavy tasks, like DBs and SSD for more generic storage. Of course you can just combine them into a single VG, but that way you are basically "slowing down" NVMe to SATA speed. Well... not really, but almost.
As for the booting - if you have EFI mode system and a modern bootloader (i.e. GRUB2) you'll need a separate small sized (256-512Mb would be fine) partition for the EFI file of FAT32 type. But at least EFI system can boot directly from NVMe and GRUB2 can boot directly from Linux RAID + LVM.
- Create 1st partition (i.e. with
fdisk
) on both the the NVMe drives of about 256-512 Mb size. Set it's type to EFI boot. - Create 2nd partition for the remaining of space for 100% allocation. Set it's type to Linux RAID.
- Format each of 1st EFI partition to FAT32 (i.e.
mkfs.vfat -F32 /dev/nvme0n1p1
). - You can follow the same for SSD drives if you want to make them bootable in case if both NVMe fail or just a single Linux RAID partition for data.
- Create a 1st RAID array for NVMe:
mdadm --create /dev/md1 -l 1 -n 2 -b internal /dev/nvme0n1p2 /dev/nvme1n1p2
. - Create a 2nd RAID array for SSD members:
mdadm --create /dev/md2 -l 1 -n 2 /dev/sda2 /dev/sdb2
(if you've created EFI partitions there or just sda1/sdb1 if not). - Create LVM PVs out of newly created arrays:
pvcreate /dev/md1 && pvcreate /dev/md2
. - Create VGs & LVs on top of the PV. If you still want to combine them, you create 2 PVs and later adding both to same VG.
- Make sure to mount EFI partitions & install a proper bootloader on each of the drives. Like this for 1st NVMe drive:
mount /dev/nvme0n1p1 /boot/efi && grub-install /dev/nvme0n1
.
Note that you can't have a RAID array for EFI partitions. Well... not really, there are some tricks, but I don't think they worth it because there is nothing unrecoverable storage on those. It's just the small binary so that the EFI "bios" can boot your bootloader. Even in case it fails, you can still boot your system of some sort of Live image (like SuperGRUBdisk) and reinstall it with grub-install again.