sbctl icon indicating copy to clipboard operation
sbctl copied to clipboard

ESP partition on MDRAID 1

Open doublez13 opened this issue 2 years ago • 1 comments

I've got the following setup on my machine...

   "blockdevices": [
      {
         "parttype": null,
         "mountpoint": "/boot",
         "pttype": null,
         "fstype": "vfat",
         "kname": "md127",
         "pkname": "nvme0n1p1",
         "type": "raid1"
      },{
         "parttype": null,
         "mountpoint": "/boot",
         "pttype": null,
         "fstype": "vfat",
         "kname": "md127",
         "pkname": "nvme1n1p1",
         "type": "raid1"
      },{
         "parttype": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
         "mountpoint": null,
         "pttype": "gpt",
         "fstype": "linux_raid_member",
         "kname": "nvme0n1p1",
         "pkname": "nvme0n1",
         "type": "part"
      },{
         "parttype": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
         "mountpoint": null,
         "pttype": "gpt",
         "fstype": "linux_raid_member",
         "kname": "nvme1n1p1",
         "pkname": "nvme1n1",
         "type": "part"
      }
   ]
}

In this particular case, the MDRAID metadata is at the back of the drives, so the motherboard just sees two identical ESP partitions, then Linux assembles them into a RAID 1.

Unfortunately sbctl fails to detect the EFI partition.

  for _, entryToCheck := range []*LsblkEntry{pathEfiEntry, pathBootEntry, pathBootEfiEntry} {
    if entryToCheck.Pttype != "gpt" {
      continue
    }

    if entryToCheck.Fstype != "vfat" {
      continue
    }

    if entryToCheck.Parttype != "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" {
      continue
    }

    return entryToCheck.Mountpoint, nil
  }

  return "", ErrNoESP

I'm wondering if it would be possible to add another check after the for loop to check for RAID? Pseudocode:

# RAID check
for entryToCheck:
  if fstype != vfat:  continue
  if type != raid1: continue
  if Pttype of parent != gpt:  continue
  if Parttype of parent != c12a7328-f81f-11d2-ba4b-00a0c93ec93b:  continue
  return entryToCheck.Mountpoint, nil

doublez13 avatar Apr 11 '23 16:04 doublez13

I have the same problem:

$ lsblk --json --output PARTTYPE,MOUNTPOINT,PTTYPE,FSTYPE,MOUNTPOINTS,TYPE,PKNAME,KNAME

Partial output:

{
   "blockdevices": [
      {
         "parttype": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
         "mountpoint": null,
         "pttype": "gpt",
         "fstype": "linux_raid_member",
         "mountpoints": [
             null
         ],
         "type": "part",
         "pkname": "sda",
         "kname": "sda3"
      },{
         "parttype": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b",
         "mountpoint": null,
         "pttype": "gpt",
         "fstype": "linux_raid_member",
         "mountpoints": [
             null
         ],
         "type": "part",
         "pkname": "sdb",
         "kname": "sdb2"
      },{
         "parttype": null,
         "mountpoint": "/efi",
         "pttype": null,
         "fstype": "vfat",
         "mountpoints": [
             "/efi"
         ],
         "type": "raid1",
         "pkname": "sdb2",
         "kname": "md127"
      },{
         "parttype": null,
         "mountpoint": "/efi",
         "pttype": null,
         "fstype": "vfat",
         "mountpoints": [
             "/efi"
         ],
         "type": "raid1",
         "pkname": "sda3",
         "kname": "md127"
      }
   ]
}

Same thing in user readable:

$ lsblk -f
NAME      FSTYPE            FSVER LABEL      MOUNTPOINTS
sda                                                                                              
├─...
└─sda3    linux_raid_member 1.0   linux:0
  └─md127 vfat              FAT32 EFI        /efi
sdb                                                                                              
├─...
└─sdb2    linux_raid_member 1.0   linux:0
  └─md127 vfat              FAT32 EFI        /efi

sedrubal avatar Feb 08 '24 22:02 sedrubal