The patch titled Subject: init/do_mounts.c: add root=PARTLABEL=<name> support has been added to the -mm tree. Its filename is init-do_mountsc-add-root=partlabel=name-support.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/init-do_mountsc-add-root%3Dpartlabel%3Dname-support.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/init-do_mountsc-add-root%3Dpartlabel%3Dname-support.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Nikolaus Voss <nikolaus.voss@xxxxxxxxxxxxxxxxxxxxx> Subject: init/do_mounts.c: add root=PARTLABEL=<name> support Support referencing the root partition label from GPT as argument to the root= option on the kernel command line in analogy to referencing the partition uuid as root=PARTUUID=<uuid>. Specifying the partition label instead of the uuid is often much easier, e.g. in embedded environments when there is an A/B rootfs partition scheme for interruptible firmware updates (i.e. rootfsA/ rootfsB). The partition label can be queried with the blkid command. Link: http://lkml.kernel.org/r/20180822060904.828E510665E@xxxxxxxxxxxxxxxxxxx Signed-off-by: Nikolaus Voss <nikolaus.voss@xxxxxxxxxxxxxxxxxxxxx> Reviewed-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx> Cc: "Levin, Alexander (Sasha Levin)" <alexander.levin@xxxxxxxxxxx> Cc: Sasha Levin <Alexander.Levin@xxxxxxxxxxxxx> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN init/do_mounts.c~init-do_mountsc-add-root=partlabel=name-support init/do_mounts.c --- a/init/do_mounts.c~init-do_mountsc-add-root=partlabel=name-support +++ a/init/do_mounts.c @@ -167,6 +167,24 @@ done: } return res; } + +/** + * match_dev_by_label - callback for finding a partition using its label + * @dev: device passed in by the caller + * @data: opaque pointer to the label to match + * + * Returns 1 if the device matches, and 0 otherwise. + */ +static int match_dev_by_label(struct device *dev, const void *data) +{ + const char *label = data; + struct hd_struct *part = dev_to_part(dev); + + if (part->info && !strcmp(label, part->info->volname)) + return 1; + + return 0; +} #endif /* @@ -190,6 +208,8 @@ done: * a partition with a known unique id. * 8) <major>:<minor> major and minor number of the device separated by * a colon. + * 9) PARTLABEL=<name> with name being the GPT partition label. + * MSDOS partitions do not support labels! * * If name doesn't have fall into the categories above, we return (0,0). * block_class is used to check if something is a disk name. If the disk @@ -211,6 +231,17 @@ dev_t name_to_dev_t(const char *name) if (!res) goto fail; goto done; + } else if (strncmp(name, "PARTLABEL=", 10) == 0) { + struct device *dev; + + dev = class_find_device(&block_class, NULL, name + 10, + &match_dev_by_label); + if (!dev) + goto fail; + + res = dev->devt; + put_device(dev); + goto done; } #endif _ Patches currently in -mm which might be from nikolaus.voss@xxxxxxxxxxxxxxxxxxxxx are init-do_mountsc-add-root=partlabel=name-support.patch