Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Whole-disk RAID and GPT/UEFI

124 views
Skip to first unread message

Nicolas George

unread,
Feb 22, 2023, 10:40:06 AM2/22/23
to
Hi.

Is there a solution to have a whole-disk RAID (software, mdadm) that is
also partitioned in GPT and bootable in UEFI?

What I imagine:

- RAID1, mirroring: if you ignore the RAID, the data is there.

- The GPT metadata is somewhere not too close to the beginning of the
drive nor too close to the end, to not conflict with the GPT, but the
space before / after the metadata is part of the RAID and synced.

- The firmware, not aware of RAID, sees a perfectly normal GPT partition
scheme, just with some unallocated space before the first partition or
after the last where the RAID metadata happen to reside.

- The kernel or a userspace tool like kpartx translates the offsets of
the GPT partitions into offsets inside the RAID, skipping the
metadata, and creates partitions inside the RAID device.

The benefit would be that the RAID would cover also the EFI partition
and the partition table itself. Since these are things that only change
at known times and are very small, the benefit is limited, but that
still would be nice.

At this time, as far as I can see: RAID metadata versions 1.0, 1.1 and
1.2 conflict with GPT because:

- 1.2 puts the superblock at sector 8;
- 1.1 puts the superblock at sector 0;
- 1.0 puts the superblock at sector end-16;
- GPT uses the sectors [0;34[ and [end-33;end[.

Metadata 0.9 uses the sectors [end-128;end-120[, not conflicting with
GPT and causing no offset for the partitions, but the data after that is
not part of the RAID, so the secondary GPT would not be synchronized.

Also, metadata 0.9 has limitations.

(I have not tested metadata ddf or imsm because they do not support
RAID1 on only one device, which is what I intend to do and what I was
testing on.)

Is there something I have missed?

Regards,

--
Nicolas George

Nicolas George

unread,
Feb 22, 2023, 11:10:06 AM2/22/23
to
DdB (12023-02-22):
> I cannot say yes or no. But, of the top of my head, i know, that gdisk
> does support a strange thing called hybrid between MBR and GPT, where a
> clean GPT formatted drive contains (instead of a protective MBR)

I have toyed with hybrid GPT in the past, in the hope to make an USB
stick that was bootable in legacy mode, bootable in UEFI mode and usable
as a regular USB stick (spoiler: it worked, until I tried it with
Windows.)

But it will not help for this issue.

> The only issue, i have had a look at, was the problem to have a raid,
> that is bootable no matter which one of the drives initially fails, a
> problem, that can be solved by having at least 2 grub installs (on the
> two mirrors).
>
> Certainly, there is a solution to your problem, even if might not
> exactly fulfill your premises.

I know of this solution. Unfortunately, that puts the partition table
and EFI partition outside the RAID: if you have to add/replace a disk,
you need to partition and reinstall GRUB, that makes a few more
manipulations on top of syncing the RAID.

Regards,

--
Nicolas George

Dan Ritter

unread,
Feb 22, 2023, 11:20:05 AM2/22/23
to
Nicolas George wrote:
> Hi.
>
> Is there a solution to have a whole-disk RAID (software, mdadm) that is
> also partitioned in GPT and bootable in UEFI?

Not that I know of. An EFI partition needs to be FAT32 or VFAT.

What I think you could do:

Partition the disks with GPT: 2 partitions each, EFI and mdadm
raid. We'll call these sda1 and sda2, and sdb1 and sdb2.

Install Debian. Use sda1 for EFI (/boot/efi), sda2/sdb2 for mdadm to create
md0.

Create a degraded mdadm mirror on sdb1, with metadata 1.0. Call
this md1.

mkfs vfat on md1. Mount it as /mnt/tmp. Get the UUID and put it in
/etc/fstab as the new value for /boot/efi.

copy everything from /boot/efi to /mnt/tmp. sync, and umount
/mnt/tmp.

wipefs /dev/sda1, then use mdadm to add it to md1.

After the resynch is finished (watch /proc/mdstat), try a
reboot.

Note that UEFI should detect this as two different boot disks,
and will not automatically switch between them. But booting
after sda fails should be as simple as switching to sdb1.

I have not tested this. I could be wrong.

-dsr-

Juri Grabowski

unread,
Feb 22, 2023, 6:40:06 PM2/22/23
to
Hello,

I have seen some installations with following setup:
GPT
sda1 sdb1 bios_grub md1 0.9
sda2 sdb2 efi md2 0.9
sda3 sdb3 /boot md3 0.9
sda4 sdb4 / md? 1.1

on such installations it's important, that grub installation is made
with "grub-install --removable"
I mean it was some grub bugs about update grub on such installations,
but if you don't blindly update the machine and reboot it shouldn't be the
problem.

Best Regards,
Juri Grabowski

Tim Woodall

unread,
Feb 23, 2023, 2:10:08 PM2/23/23
to
On Wed, 22 Feb 2023, Nicolas George wrote:

> Hi.
>
> Is there a solution to have a whole-disk RAID (software, mdadm) that is
> also partitioned in GPT and bootable in UEFI?
>

I've wanted this but settled for using dd to copy the start of the disk,
fdisk to rewrite the GPT properly then mdadm to rebuild the raid on the
remainder.

My understanding is that UEFI can potentially write, bypassing the raid
and causing the two drives to be out of sync anyway. I think only
hardware raid where the bios thinks it's a single disk can avoid this
(or software raid aware bios I guess)

David Christensen

unread,
Feb 24, 2023, 4:10:06 AM2/24/23
to
On 2/23/23 11:05, Tim Woodall wrote:
> On Wed, 22 Feb 2023, Nicolas George wrote:
>> Is there a solution to have a whole-disk RAID (software, mdadm) that is
>> also partitioned in GPT and bootable in UEFI?

> I've wanted this ...

> I think only hardware raid where the bios thinks it's a single disk ...


My wants and thinking are the same. I can and do FOSS RAID for data
disks, but I am baffled for boot disks.


I did desktop motherboard simple hardware RAID years ago (0, 1, 10,
JBOD; Intel Matrix Storage Technology?). It was configured via BIOS
Setup. I seem to recall that both Windows and Linux saw the RAID as a
single SATA HDD. Under Windows, you could download an Intel driver and
controller app to configure and/or monitor the RAID. I do not recall a
driver and app for Linux.


I believe my newer motherboards/ computers also include simple hardware
RAID. The current Intel solution is Rapid Storage Technology. I
believe this is enabled on my Dells via UEFI Setup -> Settings -> System
Configuration -> SATA Operation -> "RAID On", but I have not attempted
to build a RAID. (Do I need the Windows driver and app?) I have
discovered that Linux cannot see the disks unless the setting is changed
to "AHCI" (?), and am curious why.


I have some 2-port SATA HBA's and believe they also support simple
hardware RAID. I assume they have a BIOS extension/ POST hotkey
configuration utility, with drivers and apps for Windows. I have used
them in BIOS computers back in the day and in UEFI computers with
backwards compatibility, but I do not know if they would work in the
newest UEFI-only computers; especially with Secure Boot.


Hardware is again becoming a walled garden more so every day; especially
with Windows 11, TPM 2, and whatever Apple does. I look forward to open
source hardware, such as RISC-V.


David
0 new messages