Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Discoverable Partition Specification support #760

Open
Kangie opened this issue Oct 20, 2024 · 3 comments
Open

[Feature Request]: Discoverable Partition Specification support #760

Kangie opened this issue Oct 20, 2024 · 3 comments
Assignees

Comments

@Kangie
Copy link
Contributor

Kangie commented Oct 20, 2024

Discoverable partitions enable systems to boot without mount points in fstab (and are a neat concept).

I can see some benefits for (e.g.) embedded deployments where we want to ship a disk image and just have it "magically" boot, as well as partition images for clusters / deployments.

This is also a documented option in the Gentoo amd64 handbook (for systemd installs, at least).

Implementation details

At a high level:

  1. Get the disk that we booted off
    • Get the XBOOTLDR or ESP that we were booted from (GUID or or something from EFI?)
    • Iterate over disks and identify which one has that GUID (DPS is only for the disk we booted from)
  2. Get list of partitions from that disk (libblkid); compare with our built-in list of DPS GUIDs.
  3. Mount any partitions that match the list of internal GUIDs and are not:
    • already mounted
    • in fstab

Follow the principle of least surprise: We should behave as close to the existing impl (i.e. systemd) as is reasonable.

References:

@navi-desu navi-desu self-assigned this Oct 20, 2024
@navi-desu
Copy link
Member

i think the best we could do is adding dps detection to mountinfo (or maybe make a new tool just for that?) and implement the core of this on a init script

@navi-desu
Copy link
Member

looked into this some today. /usr, /var, /home, /srv, and all, seems easy enough to do, but

i'm unsure how openrc would mount root tho, since we only actually start after it is already mounted, and we already have /etc and /run and stuff

@awilfox
Copy link

awilfox commented Oct 23, 2024

The following post quotes the DPS linked above.

should automatically discover and mount the first root partition that does not have the no-auto flag set (as described above) by scanning the disk containing the currently used EFI ESP.

This is accomplished with i.e.:

awilcox on lab-x86_64-lin-2 ~ % efivar -l
4a67b082-0a4c-41cf-b6c7-440b29bb8c4f-LoaderDevicePartUUID
awilcox on lab-x86_64-lin-2 ~ % efivar -n 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f-LoaderDevicePartUUID -p
GUID: 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
Name: "LoaderDevicePartUUID"
Attributes:
	Boot Service Access
	Runtime Service Access
Value:
00000000  34 00 31 00 37 00 32 00  65 00 33 00 38 00 39 00  |4.1.7.2.e.3.8.9.|
00000010  2d 00 66 00 30 00 38 00  65 00 2d 00 34 00 64 00  |-.f.0.8.e.-.4.d.|
00000020  63 00 37 00 2d 00 61 00  37 00 63 00 35 00 2d 00  |c.7.-.a.7.c.5.-.|
00000030  31 00 32 00 66 00 37 00  63 00 31 00 35 00 39 00  |1.2.f.7.c.1.5.9.|
00000040  61 00 31 00 32 00 38 00  00 00                    |a.1.2.8...      |

->

lab-x86_64-lin-2 /home/awilcox # ls /sys/firmware/efi/efivars/LoaderDevicePartUUID*
/sys/firmware/efi/efivars/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
lab-x86_64-lin-2 /home/awilcox # # note that the \x00s are included, so we need to strip them:
lab-x86_64-lin-2 /home/awilcox # echo $(cat /sys/firmware/efi/efivars/LoaderDevicePartUUID-4a67b082-0a4c-41cf-b6c7-440b29bb8c4f)
   4 1 7 2 e 3 8 9 - f 0 8 e - 4 d c 7 - a 7 c 5 - 1 2 f 7 c 1 5 9 a 1 2 8   
lab-x86_64-lin-2 /home/awilcox # blkid -t PARTUUID=$(cat /sys/firmware/efi/efivars/LoaderDevicePartUUID* | tr -d '[:cntrl:]')   
/dev/nvme0n1p2: UUID="8B69-AC94" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="4172e389-f08e-4dc7-a7c5-12f7c159a128"

It should automatically discover and mount the first /usr/, /home/, /srv/, /var/, /var/tmp/ and swap partitions that do not have the no-auto flag set by scanning the disk containing the discovered root partition. It should automatically discover and mount the partition containing the currently used EFI ESP to /efi/ (or /boot/ as fallback).

So the PARTUUID that we find needs to be mounted at /efi or, if that mount point does not exist, /boot.

User configuration shall always override automatic discovery and mounting. If a root, /usr/, /home/, /srv/, /boot/, /var/, /var/tmp/, /efi/, /boot/ or swap partition is listed in /etc/fstab or with root= on the kernel command line, it must take precedence over automatically discovered partitions.

So if root is already mounted, skip it.

If a /home/, /usr/, /srv/, /boot/, /var/, /var/tmp/, /efi/ or /boot/ directory is found to be populated already in the root partition, the automatic discovery must not mount any discovered file system over it.

Hope this helps. If you need further clarification, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants