Installing Debian onto Mirrored rootfs (Soft RAID 1)

SSD Mirror
Introduction

I’ve been in the process of upgrading my server… going all the way from the modest i5 7500T all the way up to a Ryzen 5 5500. Since I started acquiring the first couple items for the new build, I had the goal of booting this machine from a mirrored pair of SSDs… This way even if one had some kind of catastrophic failure, I can still boot from the second drive and replace the failed one when convenient. Now, I must state the obligatory “RAID IS NOT A BACKUP!”… If and when something gets screwed up, it will immediately screw up both copies instantaneously. So you’re really only protected from an actual disk failure. Frequent backups are still something one must do, to protect from all other scenarios.

So, why are we here?

Glad you asked! Some Linux distributions have evolved to be a bit more ‘helpful’ in scenarios like this… for example, while it isn’t as easy as it perhaps could be, Fedora had absolutely no problem doing what I wanted the first try. No fuss. It just worked.

Debian on the other hand… I’ll admit I re-installed 3 or 4 times. Once I realized the problem, it was obvious… But if you’re reading this, you’re probably wondering what the problem is!? Why won’t this junk work??

What worked for me

So, what we need to understand here are a couple of limitations. I’m not totally sure if they’re limits of EFI, grub, or debian’s specific configuration but none the less, this is what I’ve learned.

You can’t put the ESP/EFI partition on your linux mdraid. What you want to do instead is, slice up both your disks like normal… in my case, I did:

— 500 MB EFI
— 477 GB RAID PARTITION
— 2 GB RAID PARTITION

Do both disks exactly the same. The key here is, set up that first partition as a normal EFI partition… and do it on BOTH disks. Once both disks are sliced up, go into the Linux Software RAID option… Create an MD device. Pick your two devices for RAID 1… Firstly the large (in my case 477 GB) partitions… Then run through again, this time pairing up the smaller ones for SWAP. Finish the MD setup.

Back on the partitioner’s main screen, you’ll now see two additional devices above your physical disks. Double-click them… setting the first one up with ext4, xfs, whatever you’d like… and a mountpoint of / for rootfs. Next, do the swap.

In each disk, ensure that the ESP/EFI partition has the bootable flag checked and the EFI System partition type has been used (not RAID, fat32, etc).

Finish the install… it should go without a hitch. Now, we’re in pretty good shape here. Everything on this Debian system will be mirrored to both disks, meaning each write is simultaneously sent to each disk. One can die, and nothing will be lost, but we still need to resolve EFI. To get our second EFI partition populated, read on…

On the initial boot

Go ahead and run lsblk and see which disk you’ve booted from. It will likely be sda but could very-well also be sdb. Whichever disk we *did not* boot from, we want to mount that disk’s EFI partition.

Make a directory, /mnt/efi2 and mount that partition there… then copy everything from /boot/efi into the mirror disk’s EFI partition.

(as root)
mkdir -p /mnt/efi2
mount /dev/sdb1 /mnt/efi2
cp -a /boot/efi/* /mnt/efi2/

Now, we’ll also install grub to that disk…

grub-install /dev/sdb
update-grub

Reboot… And try booting into your other SSD. It should work!

© 2025 LostGeek.NET - All Rights Reserved. Powered by ClassicPress, NGINX, Debian GNU/Linux.