summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-07 04:31:26 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-07 04:31:26 +0100
commit73b80ec2d999c45ce13f3e034704249d80829f7e (patch)
treea7ef3de874917e6b7d0c72bc74b2dd5b40480733 /src/shared
parent329f7803ee4414cd015e6f83a835079208608171 (diff)
gpt-auto-generator: automatically find the root disk of the system
When run in an initrd and no root= argument is set (or is set to root=gpt-auto) we will automatically look for the root partition on the same disk the EFI ESP is located on. Since we look for swap, /home and /srv on the disk the root partition is located on, we hence have a fully discoverable chain: Firmware discovers the EFI ESP partition → the initrd discovers the root partition → the host OS discovers swap, /home, and /srv. Note that this requires an EFI boot loader that sets the LoaderDevicePartUUID EFI variable, such as Gummiboot.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/efivars.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/shared/efivars.c b/src/shared/efivars.c
index 5ee8f1eb0b..f18f5c4b16 100644
--- a/src/shared/efivars.c
+++ b/src/shared/efivars.c
@@ -440,9 +440,6 @@ int efi_loader_get_boot_usec(usec_t *firmware, usec_t *loader) {
int efi_loader_get_device_part_uuid(sd_id128_t *u) {
_cleanup_free_ char *p = NULL;
int r, parsed[16];
- unsigned i;
-
- assert(u);
r = efi_get_variable_string(EFI_VENDOR_LOADER, "LoaderDevicePartUUID", &p);
if (r < 0)
@@ -455,8 +452,12 @@ int efi_loader_get_device_part_uuid(sd_id128_t *u) {
&parsed[12], &parsed[13], &parsed[14], &parsed[15]) != 16)
return -EIO;
- for (i = 0; i < ELEMENTSOF(parsed); i++)
- u->bytes[i] = parsed[i];
+ if (u) {
+ unsigned i;
+
+ for (i = 0; i < ELEMENTSOF(parsed); i++)
+ u->bytes[i] = parsed[i];
+ }
return 0;
}