I have a CentOS 8 installation, where the partitioning and RAID 1 configuration where done using the automatic partitioning of the CentOS installer. Here is the output of lsblk:

sda         8:0    0 558.9G  0 disk
├─sda1      8:1    0    50G  0 part
│ └─md127   9:127  0    50G  0 raid1 /
├─sda2      8:2    0    20G  0 part
│ └─md126   9:126  0    20G  0 raid1 [SWAP]
├─sda3      8:3    0     1G  0 part
│ └─md125   9:125  0  1022M  0 raid1 /boot
├─sda4      8:4    0   600M  0 part
│ └─md124   9:124  0   600M  0 raid1 /boot/efi
└─sda5      8:5    0 487.3G  0 part
  └─md123   9:123  0 487.2G  0 raid1 /home
sdb         8:16   0 558.9G  0 disk
├─sdb1      8:17   0    50G  0 part
│ └─md127   9:127  0    50G  0 raid1 /
├─sdb2      8:18   0    20G  0 part
│ └─md126   9:126  0    20G  0 raid1 [SWAP]
├─sdb3      8:19   0     1G  0 part
│ └─md125   9:125  0  1022M  0 raid1 /boot
├─sdb4      8:20   0   600M  0 part
│ └─md124   9:124  0   600M  0 raid1 /boot/efi
└─sdb5      8:21   0 487.3G  0 part
  └─md123   9:123  0 487.2G  0 raid1 /home

As you can see, the /boot/efi partition is mirrored in RAID 1 as any other partition. Now, I'm trying to recreate the same setup when installing Debian, and I'm unable to proceed. If I setup the partitions and RAID 1 in this way, I get an failure from the installer during the grub installation (with no other error message, just "Some installation step has failed" generic message).



The error goes away if I do not mirror the ESP partition.

I realise that mirroring the ESP partition is something that sounds unfeasible, and looking around it seems everybody agrees. But the CentOS installer manages to do it somehow.

What do I have to do to recreate the same setup on Debian?

  • try just using just sda4 for /boot/efi, and then turn it into a raid-1 mirror with mdadm after the system has installed and booted. BTW, a raid-1 mirror of the ESP partition is fine (but don't use other raid types like raid-0 or 10 or 5 or 6), but remember that you'll have to tell your UEFI to use the other disk if the primary disk dies - UEFI doesn't understand linux mdadm raid and won't automatically switch to the mirror.
    – cas
    Apr 8 at 12:12
  • So the steps after installation are: to create the md device, format the partition as FAT32, change its type to ESP with parted/fdisk/etc, mount it again to /boot/efi, and then how to I tell grub to repopulate it again?
    – gigabytes
    Apr 8 at 12:54
  • Make a degraded raid-1 using only /dev/sdb4. format it as FAT32, mount it somewhere convenient (/mnt, perhaps) and copy everything from /boot/efi to it (use cp -a or rsync or some other method that recurses any sub-directories). unmount /boot/efi and then add /dev/sda4 to the raid-1 with sdb4. This will cause sda4 to be synced with the contents of sdb4. Unmount this raid-1 mirror and remount it as /boot/efi (and don't forget to update /etc/fstab so that it mounts the mirror device instead of /dev/sda4 - use a LABEL or UUID instead of a /dev/ entry).
    – cas
    Apr 8 at 13:05
  • Thanks, so the contents of /boot/efi cannot be "recreated" from the grub package? Just curious.
    – gigabytes
    Apr 8 at 13:09
  • If you need more details, there are numerous questions with answers here on this site with detailed instructions for doing this kind of thing with degraded (i.e. missing one or more devices) raid mirrors. e.g. unix.stackexchange.com/questions/63928/…
    – cas
    Apr 8 at 13:10

Thanks to the comments by @cas I had this working.

The steps are mainly:

  1. I've installed Debian without setting up the RAID for the ESP partition. During the partitioning, I've already created two identical partitions marked as ESP partitions. They were on /dev/sda1 and /dev/sdb1
  2. I've copied the contents of /boot/efi somewhere else (/boot/eficopy).
  3. umount /boot/efi
  4. mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 --metadata=0.90 /dev/sda1 /dev/sdb1. Of course change /dev/md3 to something else if /dev/md3 is already an active MD device
  5. mkfs.vfat /dev/md3
  6. found the UUID of the partition in /dev/disk/by-uuid
  7. changed the /boot/efi entry in /etc/fstab with the new UUID
  8. mount /boot/efi
  9. copied the data from the backup into /boot/efi again

The reboot worked.

EDIT: Instead of backing up the /boot/efi partition, it seems that

grub-install --efi-directory=/boot/efi

does the job of restoring its contents (at step 9 above), even though I got a lot of warnings I cannot understand.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.