Scripting
UEFI Raid 1 Boot
How I set up booting from RAID1? EFI Drives
- Partition Layout
I wouldn't ordinarily have done it this way. However this was migrated from a non-UEFI gpt based boot with /boot a folder within the md0 array.
I also started with a superflous and too small esp on the beginning of the drives
Disk /dev/sda: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: BDA032EB-414E-43C6-AA73-AAF2366475A8 Device Start End Sectors Size Type /dev/sda2 4096 209719295 209715200 100G Linux RAID /dev/sda3 209719296 5860123534 5650404239 2.6T Linux RAID /dev/sda4 5860124672 5860513791 389120 190M EFI System Disk /dev/sdb: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: gpt Disk identifier: BDA032EB-414E-43C6-AA73-AAF2366475A8 Device Start End Sectors Size Type /dev/sdb2 4096 209719295 209715200 100G Linux RAID /dev/sdb3 209719296 5860123534 5650404239 2.6T Linux RAID /dev/sdb4 5860124672 5860513791 389120 190M EFI System
Procedure:
- Create EFI partitions on sda and sdb
note:
- these are not of fd00 linux raid type
- these have tags of 'efi' and 'boot'
- Make an array out of them using mdadm metadata 1.0 (not higher due to superblock needing to be at end of array)
mdadm --create /dev/md2 --metadata=1.0 --raid-devices=2 level=1 /dev/sd[ab]4
- move /boot to /boot.bak
- mkdir /boot
- add md2 (I used UUID) to mount to /boot
- mount /boot
- rsync /boot.bak /boot
- install refind-bin
- edit /etc/default/grub and make sure it has the raid modules:
GRUB_PRELOAD_MODULES="part_gpt part_msdos mdraid09 mdraid1x"
- run grub install
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB grub-mkconfig -o /boot/grub/grub.cfg
- run refind-install
[root@mythbox ~]# refind-install ShimSource is none Installing rEFInd on Linux.... ESP was found at /boot using vfat Found rEFInd installation in /boot/EFI/refind; upgrading it. Copied rEFInd binary files Notice: Backed up existing icons directory as icons-backup. Existing refind.conf file found; copying sample file as refind.conf-sample to avoid overwriting your customizations. Could not identify ESP in AddBootEntry()! Existing //boot/refind_linux.conf found; not overwriting.
This installs the loader to /boot/ESP/refind but note the missing ESP boot entry
[root@mythbox ~]# efibootmgr -v BootCurrent: 0003 Timeout: 1 seconds BootOrder: 0003,0000 Boot0000* P4: ATAPI DVD A DH16ACSH BBS(CDROM,P4: ATAPI DVD A DH16ACSH ,0x0)........................7.....................................v......& . Boot0003* UEFI: SanDisk SDDR-113 1.00 PciRoot(0x0)/Pci(0x1a,0x0)/USB(1,0)/USB(5,0)/HD(1,GPT,c271db03-317d-44ed-aad3-1a7c34d614c7,0x800,0x305f)AMBO
- Installing without specifying drives does not work (EFI does not detect drives because it cannot recognise RAID). You can see this becaue it has 0000.... id
[root@mythbox refind]# efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFInd BootCurrent: 0003 Timeout: 1 seconds BootOrder: 0001,0003,0000 Boot0000* P4: ATAPI DVD A DH16ACSH Boot0003* UEFI: SanDisk SDDR-113 1.00 Boot0001* rEFInd [root@mythbox ~]# efibootmgr -v BootCurrent: 0003 Timeout: 1 seconds BootOrder: 0006,0005,0004,0002,0001,0003,0000 Boot0000* P4: ATAPI DVD A DH16ACSH BBS(CDROM,P4: ATAPI DVD A DH16ACSH ,0x0)........................7.....................................v......& . Boot0001* rEFInd HD(1,GPT,00000000-0000-0000-0000-000000000000,0x0,0x1)/File(\EFI\refind\refind_x64.efi) Boot0003* UEFI: SanDisk SDDR-113 1.00 PciRoot(0x0)/Pci(0x1a,0x0)/USB(1,0)/USB(5,0)/HD(1,GPT,c271db03-317d-44ed-aad3-1a7c34d614c7,0x800,0x305f)AMBO
- Installing using the sd(a/b) works, although you need to give them separate names (I suffixed Md(a/b)
[root@mythbox ~]# efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFIndMdb -d /dev/sdb -p 4 BootCurrent: 0003 Timeout: 1 seconds BootOrder: 0005,0004,0002,0001,0003,0000 Boot0000* P4: ATAPI DVD A DH16ACSH Boot0003* UEFI: SanDisk SDDR-113 1.00 Boot0005* rEFIndMdb [root@mythbox ~]# efibootmgr -c -l \\EFI\\refind\\refind_x64.efi -L rEFIndMda -d /dev/sda -p 4 BootCurrent: 0003 Timeout: 1 seconds BootOrder: 0006,0005,0004,0002,0001,0003,0000 Boot0000* P4: ATAPI DVD A DH16ACSH Boot0003* UEFI: SanDisk SDDR-113 1.00 Boot0005* rEFIndMdb Boot0006* rEFIndMda [root@mythbox ~]# efibootmgr -v BootCurrent: 0003 Timeout: 1 seconds BootOrder: 0006,0005,0003,0000 Boot0000* P4: ATAPI DVD A DH16ACSH BBS(CDROM,P4: ATAPI DVD A DH16ACSH ,0x0)........................7.....................................v......& . Boot0003* UEFI: SanDisk SDDR-113 1.00 PciRoot(0x0)/Pci(0x1a,0x0)/USB(1,0)/USB(5,0)/HD(1,GPT,c271db03-317d-44ed-aad3-1a7c34d614c7,0x800,0x305f)AMBO Boot0005* rEFIndMdb HD(4,GPT,75314244-96d7-47d6-afc7-ca1d5d7ee366,0x15d4a6800,0x5f000)/File(\EFI\refind\refind_x64.efi) Boot0006* rEFIndMda HD(4,GPT,af4cf321-7fe3-4c7f-b954-637abe1287d0,0x15d4a6800,0x5f000)/File(\EFI\refind\refind_x64.efi)
This basically means that it will try the ESP on sda, then sdb if sda missing